You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ro...@apache.org on 2019/02/15 11:30:54 UTC

[lucene-solr] branch master updated: SOLR-13126: Correctly combine multiplicative query boosts

This is an automated email from the ASF dual-hosted git repository.

romseygeek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/master by this push:
     new 10acaf0  SOLR-13126: Correctly combine multiplicative query boosts
10acaf0 is described below

commit 10acaf02f82f4fc9c08884a7d249658ca6a590c1
Author: Alan Woodward <ro...@apache.org>
AuthorDate: Fri Feb 15 10:09:11 2019 +0000

    SOLR-13126: Correctly combine multiplicative query boosts
---
 .../org/apache/lucene/queries/function/ValueSource.java  |  5 ++++-
 solr/CHANGES.txt                                         |  3 +++
 .../src/test/org/apache/solr/search/TestQueryTypes.java  | 16 ++++++++++++++++
 3 files changed, 23 insertions(+), 1 deletion(-)

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.java
index 209fb15..221e822 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 {
           }
           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;
         }
       };
     }
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index b0e4a3f..112d70f 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() 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
 ----------------------
 
diff --git a/solr/core/src/test/org/apache/solr/search/TestQueryTypes.java b/solr/core/src/test/org/apache/solr/search/TestQueryTypes.java
index ff05e1a..7f9abb5 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 queries
     assertQ("test matching switch query",
             req("df", "v_t",