You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ja...@apache.org on 2019/04/25 11:40:43 UTC

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

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

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


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

commit 53d48e21b499c321c4ebd2dc55b24565a72f6e0c
Author: Jan Høydahl <ja...@apache.org>
AuthorDate: Thu Apr 25 13:00:59 2019 +0200

    SOLR-13126: Correctly combine multiplicative query boosts
    
    (Cherry pick 03945a9f5932ee78bbaa46becb551f348bca509e and backport, fix CHANGES)
---
 .../org/apache/lucene/queries/function/ValueSource.java  |  5 ++++-
 solr/CHANGES.txt                                         |  5 ++++-
 .../src/test/org/apache/solr/search/TestQueryTypes.java  | 16 ++++++++++++++++
 3 files changed, 24 insertions(+), 2 deletions(-)

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 0c65546..c2531d3 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
@@ -226,7 +226,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 52fb538..3ad2123 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -57,7 +57,7 @@ Bug fixes
 * SOLR-11876: In-place update fails when resolving from Tlog if schema has a required field (Justin Deoliveira, janhoy,
   Ishan Chattopadhyaya)
 
-  * SOLR-13349: High CPU usage in Solr due to Java 8 bug (Erick Erickson)
+* SOLR-13349: High CPU usage in Solr due to Java 8 bug (Erick Erickson)
 
 * SOLR-13355: 'all' permission ignored by RuleBasedAuthorizationPlugin in most cases (Jason Gerlowski, janhoy)
 
@@ -75,6 +75,9 @@ Bug fixes
 
 * SOLR-13409: Disable HTML directory listings in admin interface to prevent possible security issues (Uwe Schindler)
 
+* SOLR-13126: Query boosts were not being combined correctly for documents where not all boost queries
+  matched (Alan Woodward, Mikhail Khludnev)
+
 ==================  7.7.1 ==================
 
 Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.
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 eb96efa..6e55512 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",