SOLR-13126: Correctly combine multiplicative query boosts

This commit is contained in:
Alan Woodward 2019-02-15 10:09:11 +00:00
parent 52a9241232
commit 10acaf02f8
3 changed files with 23 additions and 1 deletions

View File

@ -216,7 +216,10 @@ public abstract class ValueSource {
}
else
scorer.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;
}
};
}

View File

@ -213,6 +213,9 @@ Bug Fixes
* SOLR-11774: langid.map.individual now works together with langid.map.keepOrig. Also the detectLanguage() API
is 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
----------------------

View File

@ -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 queries
assertQ("test matching switch query",
req("df", "v_t",