Module org.apache.lucene.core
Class BM25Similarity.BM25Scorer
java.lang.Object
org.apache.lucene.search.similarities.Similarity.SimScorer
org.apache.lucene.search.similarities.BM25Similarity.BM25Scorer
- Enclosing class:
- BM25Similarity
Collection statistics for the BM25 model.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final float
The average document length.private final float
b value for length normalization impactprivate final float
query boostprivate final float[]
precomputed norm[256] with k1 * ((1 - b) + b * dl / avgdl)private final Explanation
BM25's idfprivate final float
k1 value for scale factorprivate final float
weight (idf * boost) -
Constructor Summary
ConstructorsConstructorDescriptionBM25Scorer
(float boost, float k1, float b, Explanation idf, float avgdl, float[] cache) -
Method Summary
Modifier and TypeMethodDescriptionexplain
(Explanation freq, long encodedNorm) Explain the score for a single documentprivate List<Explanation>
private Explanation
explainTF
(Explanation freq, long norm) float
score
(float freq, long encodedNorm) Score a single document.
-
Field Details
-
boost
private final float boostquery boost -
k1
private final float k1k1 value for scale factor -
b
private final float bb value for length normalization impact -
idf
BM25's idf -
avgdl
private final float avgdlThe average document length. -
cache
private final float[] cacheprecomputed norm[256] with k1 * ((1 - b) + b * dl / avgdl) -
weight
private final float weightweight (idf * boost)
-
-
Constructor Details
-
BM25Scorer
BM25Scorer(float boost, float k1, float b, Explanation idf, float avgdl, float[] cache)
-
-
Method Details
-
score
public float score(float freq, long encodedNorm) Description copied from class:Similarity.SimScorer
Score a single document.freq
is the document-term sloppy frequency and must be finite and positive.norm
is the encoded normalization factor as computed bySimilarity.computeNorm(FieldInvertState)
at index time, or1
if norms are disabled.norm
is never0
.Score must not decrease when
freq
increases, ie. iffreq1 > freq2
, thenscore(freq1, norm) >= score(freq2, norm)
for any value ofnorm
that may be produced bySimilarity.computeNorm(FieldInvertState)
.Score must not increase when the unsigned
norm
increases, ie. ifLong.compareUnsigned(norm1, norm2) > 0
thenscore(freq, norm1) <= score(freq, norm2)
for any legalfreq
.As a consequence, the maximum score that this scorer can produce is bound by
score(Float.MAX_VALUE, 1)
.- Specified by:
score
in classSimilarity.SimScorer
- Parameters:
freq
- sloppy term frequency, must be finite and positiveencodedNorm
- encoded normalization factor or1
if norms are disabled- Returns:
- document's score
-
explain
Description copied from class:Similarity.SimScorer
Explain the score for a single document- Overrides:
explain
in classSimilarity.SimScorer
- Parameters:
freq
- Explanation of how the sloppy term frequency was computedencodedNorm
- encoded normalization factor, as returned bySimilarity.computeNorm(org.apache.lucene.index.FieldInvertState)
, or1
if norms are disabled- Returns:
- document's score
-
explainTF
-
explainConstantFactors
-