mirror of https://github.com/apache/lucene.git
fix explain to factor in outer boost
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1180599 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c45396602a
commit
1912c6c9c6
|
@ -277,6 +277,8 @@ public class BM25Similarity extends Similarity {
|
||||||
private final float avgdl;
|
private final float avgdl;
|
||||||
/** query's inner boost */
|
/** query's inner boost */
|
||||||
private final float queryBoost;
|
private final float queryBoost;
|
||||||
|
/** query's outer boost (only for explain) */
|
||||||
|
private float topLevelBoost;
|
||||||
/** weight (idf * boost) */
|
/** weight (idf * boost) */
|
||||||
private float weight;
|
private float weight;
|
||||||
/** precomputed norm[256] with k1 * ((1 - b) + b * dl / avgdl) */
|
/** precomputed norm[256] with k1 * ((1 - b) + b * dl / avgdl) */
|
||||||
|
@ -299,6 +301,7 @@ public class BM25Similarity extends Similarity {
|
||||||
@Override
|
@Override
|
||||||
public void normalize(float queryNorm, float topLevelBoost) {
|
public void normalize(float queryNorm, float topLevelBoost) {
|
||||||
// we don't normalize with queryNorm at all, we just capture the top-level boost
|
// we don't normalize with queryNorm at all, we just capture the top-level boost
|
||||||
|
this.topLevelBoost = topLevelBoost;
|
||||||
this.weight = idf.getValue() * queryBoost * topLevelBoost;
|
this.weight = idf.getValue() * queryBoost * topLevelBoost;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -307,8 +310,8 @@ public class BM25Similarity extends Similarity {
|
||||||
Explanation result = new Explanation();
|
Explanation result = new Explanation();
|
||||||
result.setDescription("score(doc="+doc+",freq="+freq+"), product of:");
|
result.setDescription("score(doc="+doc+",freq="+freq+"), product of:");
|
||||||
|
|
||||||
Explanation boostExpl = new Explanation(stats.queryBoost, "boost");
|
Explanation boostExpl = new Explanation(stats.queryBoost * stats.topLevelBoost, "boost");
|
||||||
if (stats.queryBoost != 1.0f)
|
if (boostExpl.getValue() != 1.0f)
|
||||||
result.addDetail(boostExpl);
|
result.addDetail(boostExpl);
|
||||||
|
|
||||||
result.addDetail(stats.idf);
|
result.addDetail(stats.idf);
|
||||||
|
|
Loading…
Reference in New Issue