Package org.apache.lucene.search
Class DefaultSimilarity
- java.lang.Object
-
- org.apache.lucene.search.Similarity
-
- org.apache.lucene.search.DefaultSimilarity
-
- All Implemented Interfaces:
Serializable
public class DefaultSimilarity extends Similarity
Expert: Default scoring implementation.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected booleandiscountOverlaps-
Fields inherited from class org.apache.lucene.search.Similarity
NO_DOC_ID_PROVIDED
-
-
Constructor Summary
Constructors Constructor Description DefaultSimilarity()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description floatcomputeNorm(String field, FieldInvertState state)Implemented asstate.getBoost()*lengthNorm(numTerms), wherenumTermsisFieldInvertState.getLength()ifsetDiscountOverlaps(boolean)is false, else it'sFieldInvertState.getLength()-FieldInvertState.getNumOverlap().floatcoord(int overlap, int maxOverlap)Implemented asoverlap / maxOverlap.booleangetDiscountOverlaps()floatidf(int docFreq, int numDocs)Implemented aslog(numDocs/(docFreq+1)) + 1.floatqueryNorm(float sumOfSquaredWeights)Implemented as1/sqrt(sumOfSquaredWeights).voidsetDiscountOverlaps(boolean v)Determines whether overlap tokens (Tokens with 0 position increment) are ignored when computing norm.floatsloppyFreq(int distance)Implemented as1 / (distance + 1).floattf(float freq)Implemented assqrt(freq).-
Methods inherited from class org.apache.lucene.search.Similarity
decodeNorm, decodeNormValue, encodeNorm, encodeNormValue, getDefault, getNormDecoder, idfExplain, idfExplain, idfExplain, lengthNorm, scorePayload, setDefault, tf
-
-
-
-
Method Detail
-
computeNorm
public float computeNorm(String field, FieldInvertState state)
Implemented asstate.getBoost()*lengthNorm(numTerms), wherenumTermsisFieldInvertState.getLength()ifsetDiscountOverlaps(boolean)is false, else it'sFieldInvertState.getLength()-FieldInvertState.getNumOverlap().- Specified by:
computeNormin classSimilarity- Parameters:
field- field namestate- current processing state for this field- Returns:
- the calculated float norm
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
queryNorm
public float queryNorm(float sumOfSquaredWeights)
Implemented as1/sqrt(sumOfSquaredWeights).- Specified by:
queryNormin classSimilarity- Parameters:
sumOfSquaredWeights- the sum of the squares of query term weights- Returns:
- a normalization factor for query weights
-
tf
public float tf(float freq)
Implemented assqrt(freq).- Specified by:
tfin classSimilarity- Parameters:
freq- the frequency of a term within a document- Returns:
- a score factor based on a term's within-document frequency
-
sloppyFreq
public float sloppyFreq(int distance)
Implemented as1 / (distance + 1).- Specified by:
sloppyFreqin classSimilarity- Parameters:
distance- the edit distance of this sloppy phrase match- Returns:
- the frequency increment for this match
- See Also:
PhraseQuery.setSlop(int)
-
idf
public float idf(int docFreq, int numDocs)Implemented aslog(numDocs/(docFreq+1)) + 1.- Specified by:
idfin classSimilarity- Parameters:
docFreq- the number of documents which contain the termnumDocs- the total number of documents in the collection- Returns:
- a score factor based on the term's document frequency
-
coord
public float coord(int overlap, int maxOverlap)Implemented asoverlap / maxOverlap.- Specified by:
coordin classSimilarity- Parameters:
overlap- the number of query terms matched in the documentmaxOverlap- the total number of terms in the query- Returns:
- a score factor based on term overlap with the query
-
setDiscountOverlaps
public void setDiscountOverlaps(boolean v)
Determines whether overlap tokens (Tokens with 0 position increment) are ignored when computing norm. By default this is true, meaning overlap tokens do not count when computing norms.- See Also:
computeNorm(java.lang.String, org.apache.lucene.index.FieldInvertState)- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
getDiscountOverlaps
public boolean getDiscountOverlaps()
- See Also:
setDiscountOverlaps(boolean)
-
-