Apache Solr open-source search software
SOLR-13126: Correctly combine multiplicative query boosts
Alan Woodward10acaf02f82f
diff --git a/lucene/queries/src/java/org/apache/lucene/queries/function/ValueSource.java b/lucene/queries/src/java/org/apache/lucene/queries/function/ValueSource.javaindex 209fb15962d..221e822d1f1 100644--- a/lucene/queries/src/java/org/apache/lucene/queries/function/ValueSource.java+++ b/lucene/queries/src/java/org/apache/lucene/queries/function/ValueSource.java@@ -216,7 +216,10 @@ public abstract class ValueSource {}elsescorer.score = 0;- return fv.exists(doc);+ // ValueSource will return values even if exists() is false, generally a default+ // of some kind. To preserve this behaviour with the iterator, we need to always+ // return 'true' here.+ return true;}};}diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex b0e4a3f24c8..112d70fa0b4 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -213,6 +213,9 @@ Bug Fixes* SOLR-11774: langid.map.individual now works together with langid.map.keepOrig. Also the detectLanguage() APIis changed to accept a Reader allowing for more memory efficient implementations (janhoy)+* SOLR-13126: Query boosts were not being combined correctly for documents where not all boost queries+ matched (Alan Woodward, Mikhail Khludnev)+Improvements----------------------diff --git a/solr/core/src/test/org/apache/solr/search/TestQueryTypes.java b/solr/core/src/test/org/apache/solr/search/TestQueryTypes.javaindex ff05e1a22f8..7f9abb5d3d8 100644--- a/solr/core/src/test/org/apache/solr/search/TestQueryTypes.java+++ b/solr/core/src/test/org/apache/solr/search/TestQueryTypes.java@@ -44,6 +44,11 @@ public class TestQueryTypes extends SolrTestCaseJ4 {assertU(adoc("id","9", "v_s","internal\"quote"));assertU(adoc("id","10","text_no_analyzer","should just work"));++ assertU(adoc("id", "200", "subject_t", "Sony Netzteil"));+ assertU(adoc("id", "201", "subject_t", "Other Netzteil"));+ assertU(adoc("id", "202", "subject_t", "Other Product"));+Object[] arr = new Object[] {"id",999,"v_s","wow dude"@@ -347,6 +352,17 @@ public class TestQueryTypes extends SolrTestCaseJ4 {,"//doc[./float[@name='v_f']='1.5' and ./float[@name='score']='2.25']");+ // multiplicative boosts combine correctly+ assertQ(+ req("q", "{!boost b=$ymb}(+{!lucene v=$yq})",+ "ymb", "product(query({!v=subject_t:Netzteil^=2.0},1),query({!v=subject_t:Sony^=3.0},1))",+ "yq", "subject_t:*",+ "fl", "*,score", "indent", "on"),+ "//doc[str[@name='id'][.='200'] and float[@name='score'][.=6.0]]",+ "//doc[str[@name='id'][.='202'] and float[@name='score'][.=1.0]]",+ "//doc[str[@name='id'][.='201'] and float[@name='score'][.=2.0]]"+ );+// switch queriesassertQ("test matching switch query",req("df", "v_t",