From 8648b005e28d24b7e18726502ae1ea5fffa44a5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20H=C3=B8ydahl?= Date: Tue, 20 Jun 2017 13:39:36 +0200 Subject: [PATCH] SOLR-4646: eDismax lowercaseOperators now defaults to "false" for luceneMatchVersion >= 7.0.0 --- solr/CHANGES.txt | 5 +++++ .../org/apache/solr/search/ExtendedDismaxQParser.java | 7 +++++-- .../apache/solr/search/TestExtendedDismaxParser.java | 10 +++++++++- .../src/the-extended-dismax-query-parser.adoc | 1 + solr/webapp/web/js/angular/controllers/query.js | 2 +- 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 9267039b657..a201d1e3e68 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -102,6 +102,9 @@ Upgrading from Solr 6.x curl http://host:8983/solr/mycollection/config -d '{"set-user-property": {"update.autoCreateFields":"false"}}' Please see SOLR-10574 for details. +* The default for eDismax parameter 'lowercaseOperators' now depends on the luceneMatchVersion setting in solrconfig. + It remains 'true' for luceneMatchVersion < 7.0.0 and changes to 'false' from 7.0.0. See also SOLR-4646 + New Features ---------------------- * SOLR-9857, SOLR-9858: Collect aggregated metrics from nodes and shard leaders in overseer. (ab) @@ -293,6 +296,8 @@ Other Changes * SOLR-9623: Disable remote streaming in example configs by default. Adjust Upload Limit defaults (janhoy, yonik) +* SOLR-4646: eDismax lowercaseOperators now defaults to "false" for luceneMatchVersion >= 7.0.0 (janhoy, David Smiley) + ================== 6.7.0 ================== Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release. diff --git a/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParser.java b/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParser.java index a68836c39ec..9ec07e84acb 100644 --- a/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParser.java +++ b/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParser.java @@ -46,6 +46,7 @@ import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.MultiPhraseQuery; import org.apache.lucene.search.PhraseQuery; import org.apache.lucene.search.Query; +import org.apache.lucene.util.Version; import org.apache.solr.analysis.TokenizerChain; import org.apache.solr.common.params.DisMaxParams; import org.apache.solr.common.params.SolrParams; @@ -1703,8 +1704,10 @@ public class ExtendedDismaxQParser extends QParser { mmAutoRelax = solrParams.getBool(DMP.MM_AUTORELAX, false); altQ = solrParams.get( DisMaxParams.ALTQ ); - - lowercaseOperators = solrParams.getBool(DMP.LOWERCASE_OPS, true); + + // lowercaseOperators defaults to true for luceneMatchVersion < 7.0 and to false for >= 7.0 + lowercaseOperators = solrParams.getBool(DMP.LOWERCASE_OPS, + !req.getCore().getSolrConfig().luceneMatchVersion.onOrAfter(Version.LUCENE_7_0_0)); /* * * Boosting Query * * */ boostParams = solrParams.getParams(DisMaxParams.BQ); diff --git a/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java b/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java index 46bebb3f2f5..0dc327db376 100644 --- a/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java +++ b/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java @@ -189,6 +189,14 @@ public class TestExtendedDismaxParser extends SolrTestCaseJ4 { "defType", "edismax") , "*[count(//doc)=0]"); + assertQ("The default for lowercaseOperators should not allow lower case and", + req("q", "Zapp and Brannigan", + "qf", "name", + "q.op", "AND", + "sow", sow, + "defType", "edismax") + , "*[count(//doc)=0]"); + assertQ("Lower case operator, allow lower case operators", req("q", "Zapp and Brannigan", "qf", "name", @@ -284,7 +292,7 @@ public class TestExtendedDismaxParser extends SolrTestCaseJ4 { "q","Order AND op"), oner ); assertQ(req("defType", "edismax", "qf", "name title subject text", - "q","Order and op"), oner + "q","Order and op"), twor ); assertQ(req("defType", "edismax", "qf", "name title subject text", "q","+Order op"), oner diff --git a/solr/solr-ref-guide/src/the-extended-dismax-query-parser.adoc b/solr/solr-ref-guide/src/the-extended-dismax-query-parser.adoc index c0fdcaeeab5..e949a61d025 100644 --- a/solr/solr-ref-guide/src/the-extended-dismax-query-parser.adoc +++ b/solr/solr-ref-guide/src/the-extended-dismax-query-parser.adoc @@ -59,6 +59,7 @@ A multivalued list of strings parsed as queries with scores multiplied by the sc === The lowercaseOperators Parameter A Boolean parameter indicating if lowercase "and" and "or" should be treated the same as operators "AND" and "OR". +Defaults to `false`. [[TheExtendedDisMaxQueryParser-ThepsParameter]] === The ps Parameter diff --git a/solr/webapp/web/js/angular/controllers/query.js b/solr/webapp/web/js/angular/controllers/query.js index 5dd105b149e..3a44cbd5a96 100644 --- a/solr/webapp/web/js/angular/controllers/query.js +++ b/solr/webapp/web/js/angular/controllers/query.js @@ -23,7 +23,7 @@ solrAdminApp.controller('QueryController', $scope.query = {wt: 'json', q:'*:*', indent:'on'}; $scope.filters = [{fq:""}]; $scope.dismax = {defType: "dismax"}; - $scope.edismax = {defType: "edismax", stopwords: true, lowercaseOperators: true}; + $scope.edismax = {defType: "edismax", stopwords: true, lowercaseOperators: false}; $scope.hl = {hl:"on"}; $scope.facet = {facet: "on"}; $scope.spatial = {};