Apache Lucene open-source search software
LUCENE-8010: Axiomatic similarities must incorporate the boost as a multiplicative factor.
Adrien Grand8dfb01907629
diff --git a/lucene/core/src/java/org/apache/lucene/search/similarities/Axiomatic.java b/lucene/core/src/java/org/apache/lucene/search/similarities/Axiomatic.javaindex 553fd428c0b..df683c14f90 100644--- a/lucene/core/src/java/org/apache/lucene/search/similarities/Axiomatic.java+++ b/lucene/core/src/java/org/apache/lucene/search/similarities/Axiomatic.java@@ -107,6 +107,7 @@ public abstract class Axiomatic extends SimilarityBase {* tfln(stats, freq, docLen)* idf(stats, freq, docLen)- gamma(stats, freq, docLen);+ score *= stats.boost;// AxiomaticF3 similarities might produce negative scores due to their gamma componentreturn Math.max(0, score);}@@ -132,6 +133,11 @@ public abstract class Axiomatic extends SimilarityBase {Explanation explanation = Explanation.match((float) score,"score(" + getClass().getSimpleName() + ", doc=" + doc + ", freq=" + freq.getValue() +"), computed from:",subs);+ if (stats.boost != 1f) {+ explanation = Explanation.match((float) (score * stats.boost), "Boosted score, computed as (score * boost) from:",+ explanation,+ Explanation.match((float) stats.boost, "Query boost"));+ }if (score < 0) {explanation = Explanation.match(0, "max of:",Explanation.match(0, "Minimum legal score"),