Class BasicStats
- java.lang.Object
-
- org.apache.lucene.search.similarities.Similarity.SimWeight
-
- org.apache.lucene.search.similarities.BasicStats
-
- Direct Known Subclasses:
LMSimilarity.LMStats
public class BasicStats extends Similarity.SimWeight
Stores all statistics commonly used ranking methods.
-
-
Field Summary
Fields Modifier and Type Field Description protected floatavgFieldLengthThe average field length.protected longdocFreqThe document frequency.protected longnumberOfDocumentsThe number of documents.protected longnumberOfFieldTokensThe total number of tokens in the field.protected floatqueryBoostQuery's inner boost.protected floattopLevelBoostAny outer query's boost.protected floattotalBoostFor most Similarities, the immediate and the top level query boosts are not handled differently.protected longtotalTermFreqThe total number of occurrences of this term across all documents.
-
Constructor Summary
Constructors Constructor Description BasicStats(String field, float queryBoost)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description floatgetAvgFieldLength()Returns the average field length.longgetDocFreq()Returns the document frequency.longgetNumberOfDocuments()Returns the number of documents.longgetNumberOfFieldTokens()Returns the total number of tokens in the field.floatgetTotalBoost()Returns the total boost.longgetTotalTermFreq()Returns the total number of occurrences of this term across all documents.floatgetValueForNormalization()The square of the raw normalization value.voidnormalize(float queryNorm, float topLevelBoost)No normalization is done.protected floatrawNormalizationValue()Computes the raw normalization value.voidsetAvgFieldLength(float avgFieldLength)Sets the average field length.voidsetDocFreq(long docFreq)Sets the document frequency.voidsetNumberOfDocuments(long numberOfDocuments)Sets the number of documents.voidsetNumberOfFieldTokens(long numberOfFieldTokens)Sets the total number of tokens in the field.voidsetTotalTermFreq(long totalTermFreq)Sets the total number of occurrences of this term across all documents.
-
-
-
Field Detail
-
numberOfDocuments
protected long numberOfDocuments
The number of documents.
-
numberOfFieldTokens
protected long numberOfFieldTokens
The total number of tokens in the field.
-
avgFieldLength
protected float avgFieldLength
The average field length.
-
docFreq
protected long docFreq
The document frequency.
-
totalTermFreq
protected long totalTermFreq
The total number of occurrences of this term across all documents.
-
queryBoost
protected final float queryBoost
Query's inner boost.
-
topLevelBoost
protected float topLevelBoost
Any outer query's boost.
-
totalBoost
protected float totalBoost
For most Similarities, the immediate and the top level query boosts are not handled differently. Hence, this field is just the product of the other two.
-
-
Constructor Detail
-
BasicStats
public BasicStats(String field, float queryBoost)
Constructor. Sets the query boost.
-
-
Method Detail
-
getNumberOfDocuments
public long getNumberOfDocuments()
Returns the number of documents.
-
setNumberOfDocuments
public void setNumberOfDocuments(long numberOfDocuments)
Sets the number of documents.
-
getNumberOfFieldTokens
public long getNumberOfFieldTokens()
Returns the total number of tokens in the field.- See Also:
Terms.getSumTotalTermFreq()
-
setNumberOfFieldTokens
public void setNumberOfFieldTokens(long numberOfFieldTokens)
Sets the total number of tokens in the field.- See Also:
Terms.getSumTotalTermFreq()
-
getAvgFieldLength
public float getAvgFieldLength()
Returns the average field length.
-
setAvgFieldLength
public void setAvgFieldLength(float avgFieldLength)
Sets the average field length.
-
getDocFreq
public long getDocFreq()
Returns the document frequency.
-
setDocFreq
public void setDocFreq(long docFreq)
Sets the document frequency.
-
getTotalTermFreq
public long getTotalTermFreq()
Returns the total number of occurrences of this term across all documents.
-
setTotalTermFreq
public void setTotalTermFreq(long totalTermFreq)
Sets the total number of occurrences of this term across all documents.
-
getValueForNormalization
public float getValueForNormalization()
The square of the raw normalization value.- Specified by:
getValueForNormalizationin classSimilarity.SimWeight- See Also:
rawNormalizationValue()
-
rawNormalizationValue
protected float rawNormalizationValue()
Computes the raw normalization value. This basic implementation returns the query boost. Subclasses may override this method to include other factors (such as idf), or to save the value for inclusion innormalize(float, float), etc.
-
normalize
public void normalize(float queryNorm, float topLevelBoost)No normalization is done.topLevelBoostis saved in the object, however.- Specified by:
normalizein classSimilarity.SimWeight
-
getTotalBoost
public float getTotalBoost()
Returns the total boost.
-
-