Apache Lucene open-source search software
SOLR-14517 Obey "mm" local param on edismax queries with operators (#1540)
Yuriy Kovalcb7e948d2ed0
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 1d13f76d6e4..6040f64d833 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -200,8 +200,11 @@ Bug Fixes* SOLR-14498: Upgrade to Caffeine 2.8.4, which fixes the cache poisoning issue. (Jakub Zytka, ab)+* SOLR-14517: Dont ignore 'mm' localparam on edismax queries using operators (Yuriy Koval via Jason Gerlowski)+* SOLR-14491: Intercepting internode requests in KerberosPlugin when HTTP/2 client is used (Ishan Chattopadhyaya, Moshe Bla)+Other Changes---------------------* SOLR-14197: SolrResourceLoader: marked many methods as deprecated, and in some cases rerouted exiting logic to avoiddiff --git a/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParser.java b/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParser.javaindex 93aaf28f1dd..9c8672c7aa2 100644--- a/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParser.java+++ b/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParser.java@@ -412,7 +412,7 @@ public class ExtendedDismaxQParser extends QParser {String mmSpec = config.minShouldMatch;if (foundOperators(clauses, config.lowercaseOperators)) {- mmSpec = params.get(DisMaxParams.MM, "0%"); // Use provided mm spec if present, otherwise turn off mm processing+ mmSpec = config.solrParams.get(DisMaxParams.MM, "0%"); // Use provided mm spec if present, otherwise turn off mm processing}query = SolrPluginUtils.setMinShouldMatch((BooleanQuery)query, mmSpec, config.mmAutoRelax);}diff --git a/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java b/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.javaindex 65e18509ef6..e16df5e92b6 100644--- a/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java+++ b/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java@@ -1220,12 +1220,8 @@ public class TestExtendedDismaxParser extends SolrTestCaseJ4 {"defType", "edismax"), "*[count(//doc)=4]");- assertQ("test minShouldMatch (top level optional terms only and sow=false)",- req("q", "stocks oil gold", // +(((text_sw:stock) (text_sw:oil) (text_sw:gold))~1)- "qf", "text_sw",- "mm", "50%",- "sow", sow,- "defType", "edismax")+ assertQ("test minShouldMatch (top level optional terms only) local mm=50%",+ req("q", "{!edismax qf=text_sw mm=50% sow=" + sow + " v='stocks oil gold'}"), "*[count(//doc)=4]");assertQ("test minShouldMatch (top level optional and negative terms mm=50%)",@@ -1236,6 +1232,10 @@ public class TestExtendedDismaxParser extends SolrTestCaseJ4 {"defType", "edismax"), "*[count(//doc)=3]");+ assertQ("test minShouldMatch (top level optional and negative terms local mm=50%)",+ req("q", "{!edismax qf=text_sw mm=50% sow=" + sow + " v='stocks oil gold -stockade'}")+ , "*[count(//doc)=3]");+assertQ("test minShouldMatch (top level optional and negative terms mm=100%)",req("q", "stocks gold -stockade", // +(((text_sw:stock) (text_sw:oil) (text_sw:gold) -(text_sw:stockad))~2)"qf", "text_sw",@@ -1244,6 +1244,10 @@ public class TestExtendedDismaxParser extends SolrTestCaseJ4 {"defType", "edismax"), "*[count(//doc)=1]");+ assertQ("test minShouldMatch (top level optional and negative terms local mm=100%)",+ req("q", "{!edismax qf=text_sw mm=100% sow=" + sow + " v='stocks gold -stockade'}")+ , "*[count(//doc)=1]");+assertQ("test minShouldMatch (top level required terms only)",req("q", "stocks AND oil", // +(+(text_sw:stock) +(text_sw:oil))"qf", "text_sw",@@ -1252,6 +1256,10 @@ public class TestExtendedDismaxParser extends SolrTestCaseJ4 {"defType", "edismax"), "*[count(//doc)=1]");+ assertQ("test minShouldMatch (top level required terms only) local mm=50%)",+ req("q", "{!edismax qf=text_sw mm=50% sow=" + sow + " v='stocks AND oil'}")+ , "*[count(//doc)=1]");+assertQ("test minShouldMatch (top level optional and required terms)",req("q", "oil gold +stocks", // +(((text_sw:oil) (text_sw:gold) +(text_sw:stock))~1)"qf", "text_sw",@@ -1260,6 +1268,10 @@ public class TestExtendedDismaxParser extends SolrTestCaseJ4 {"defType", "edismax"), "*[count(//doc)=3]");+ assertQ("test minShouldMatch (top level optional and required terms) local mm=50%)",+ req("q", "{!edismax qf=text_sw mm=50% sow=" + sow + " v='oil gold +stocks'}")+ , "*[count(//doc)=3]");+assertQ("test minShouldMatch (top level optional with explicit OR and parens)",req("q", "(snake OR stocks) oil","qf", "text_sw",@@ -1268,6 +1280,10 @@ public class TestExtendedDismaxParser extends SolrTestCaseJ4 {"defType", "edismax"), "*[count(//doc)=2]");+ assertQ("test minShouldMatch (top level optional with explicit OR and parens) local mm=100%)",+ req("q", "{!edismax qf=text_sw mm=100% sow=" + sow + " v='(snake OR stocks) oil'}")+ , "*[count(//doc)=2]");+// The results for these two appear odd, but are correct as per BooleanQuery processing.// See: http://searchhub.org/2011/12/28/why-not-and-or-and-not/// Non-parenthesis OR/AND precedence is not true to abstract boolean logic in solr when q.op = AND@@ -1280,6 +1296,11 @@ public class TestExtendedDismaxParser extends SolrTestCaseJ4 {"sow", sow,"defType", "edismax"), "*[count(//doc)=0]");++ assertQ("test minShouldMatch (top level optional with explicit OR without parens) local mm=100%)",+ req("q", "{!edismax qf=text_sw q.op=OR mm=100% sow=" + sow + " v='snake OR stocks oil'}")+ , "*[count(//doc)=0]");+assertQ("test minShouldMatch (top level optional with explicit OR without parens)",req("q", "snake OR stocks oil","qf", "text_sw",@@ -1289,6 +1310,10 @@ public class TestExtendedDismaxParser extends SolrTestCaseJ4 {"defType", "edismax"), "*[count(//doc)=0]");+ assertQ("test minShouldMatch (top level optional with explicit OR without parens) local mm=100%)",+ req("q", "{!edismax qf=text_sw q.op=AND mm=100% sow=" + sow + " v='snake OR stocks oil'}")+ , "*[count(//doc)=0]");+// SOLR-9174assertQ("test minShouldMatch=1<-1 with explicit OR, one impossible clause, and no explicit q.op",req("q", "barbie OR (hair AND nonexistentword)",@@ -1297,6 +1322,10 @@ public class TestExtendedDismaxParser extends SolrTestCaseJ4 {"sow", sow,"defType", "edismax"), "*[count(//doc)=3]");++ assertQ("test local minShouldMatch=1<-1 with explicit OR, one impossible clause, and no explicit q.op",+ req("q", "{!edismax qf=text_sw mm=1<-1 sow=" + sow + " v='barbie OR (hair AND nonexistentword)'}")+ , "*[count(//doc)=3]");}}