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 2017/05/04 19:38:34 UTC

lucene-solr:branch_6x: SOLR-10586: Ban defaultOperator in schema for luceneMatchVersion =>6.6.0

Repository: lucene-solr
Updated Branches:
  refs/heads/branch_6x b59f816e6 -> f3ac0c417


SOLR-10586: Ban defaultOperator in schema for luceneMatchVersion =>6.6.0


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/f3ac0c41
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/f3ac0c41
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/f3ac0c41

Branch: refs/heads/branch_6x
Commit: f3ac0c417860e5e8a850c3248d8e6ff3207f125b
Parents: b59f816
Author: Jan Høydahl <ja...@apache.org>
Authored: Thu May 4 14:08:48 2017 +0200
Committer: Jan Høydahl <ja...@apache.org>
Committed: Thu May 4 21:14:51 2017 +0200

----------------------------------------------------------------------
 solr/CHANGES.txt                                |  7 +++
 .../org/apache/solr/schema/IndexSchema.java     | 21 +++++--
 .../org/apache/solr/search/QueryParsing.java    |  2 +
 .../conf/bad-schema-default-operator.xml        | 26 +++++++++
 .../conf/solrconfig-minimal-version6.xml        | 59 ++++++++++++++++++++
 .../apache/solr/schema/BadIndexSchemaTest.java  | 11 +++-
 6 files changed, 119 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f3ac0c41/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 0a33ab9..c3ac46a 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -39,6 +39,10 @@ Upgrade Notes
 
 * ZooKeeper dependency has been upgraded from 3.4.6 to 3.4.10.
 
+* Setting <solrQueryParser defaultOperator="..."/> in schema is no longer allowed and will cause an exception,
+  but older configs with luceneMatchVersion < 6.6 will still work as before.
+  Please use "q.op" parameter on the request instead. For more details, see SOLR-10586.
+
 Detailed Change List
 ----------------------
 New Features
@@ -232,6 +236,9 @@ Other Changes
 * SOLR-9867: Adding isLoading=true as core status. Fixing start after stop scenario in bin/solr
   (Andrey Kudryavtsev, Mikhail Khludnev)
 
+* SOLR-10586: Ban defaultOperator in schema for luceneMatchVersion =>6.6.0
+  Method IndexSchema.getQueryParserDefaultOperator is deprecated and will go away in 7.0 (janhoy)
+
 ==================  6.5.1 ==================
 
 Bug Fixes

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f3ac0c41/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/schema/IndexSchema.java b/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
index 2ea63d4..5e9e87b 100644
--- a/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
+++ b/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
@@ -314,7 +314,9 @@ public class IndexSchema {
 
   /**
    * default operator ("AND" or "OR") for QueryParser
+   * @deprecated this will go away in Solr 7.0
    */
+  @Deprecated
   public String getQueryParserDefaultOperator() {
     return queryParserDefaultOperator;
   }
@@ -542,13 +544,20 @@ public class IndexSchema {
       //                      /schema/solrQueryParser/@defaultOperator
       expression = stepsToPath(SCHEMA, SOLR_QUERY_PARSER, AT + DEFAULT_OPERATOR);
       node = (Node) xpath.evaluate(expression, document, XPathConstants.NODE);
-      if (node==null) {
-        log.debug("Default query parser operator not set in Schema");
+      if (node != null) {
+        // Fail fast for new >=6.6 configs. Will always fail from 7.0.0
+        if (getDefaultLuceneMatchVersion().onOrAfter(Version.LUCENE_6_6_0)) {
+          throw new SolrException(ErrorCode.SERVER_ERROR,
+              "Setting default operator in schema (solrQueryParser/@defaultOperator) not supported");
+        } else {
+          isExplicitQueryParserDefaultOperator = true;
+          queryParserDefaultOperator=node.getNodeValue().trim();
+          log.warn("[{}] query parser default operator is {}. WARNING: Deprecated, please use 'q.op' on request instead. "
+              + "Will not work from Solr 7",
+              coreName, queryParserDefaultOperator);
+        }
       } else {
-        isExplicitQueryParserDefaultOperator = true;
-        queryParserDefaultOperator=node.getNodeValue().trim();
-        log.warn("[{}] query parser default operator is {}. WARNING: Deprecated, please use 'q.op' on request instead.",
-            coreName, queryParserDefaultOperator);
+        log.debug("Default query parser operator not set in Schema");
       }
 
       //                      /schema/uniqueKey/text()

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f3ac0c41/solr/core/src/java/org/apache/solr/search/QueryParsing.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/QueryParsing.java b/solr/core/src/java/org/apache/solr/search/QueryParsing.java
index 077ae67..f6c5df5 100644
--- a/solr/core/src/java/org/apache/solr/search/QueryParsing.java
+++ b/solr/core/src/java/org/apache/solr/search/QueryParsing.java
@@ -65,7 +65,9 @@ public class QueryParsing {
    *
    * @see IndexSchema#getQueryParserDefaultOperator()
    * @see #OP
+   * @deprecated this will probably be removed in 8.x. Keeping in 7.x for code back compat
    */
+  @Deprecated
   public static QueryParser.Operator getQueryParserDefaultOperator(final IndexSchema sch,
                                                        final String override) {
     String val = override;

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f3ac0c41/solr/core/src/test-files/solr/collection1/conf/bad-schema-default-operator.xml
----------------------------------------------------------------------
diff --git a/solr/core/src/test-files/solr/collection1/conf/bad-schema-default-operator.xml b/solr/core/src/test-files/solr/collection1/conf/bad-schema-default-operator.xml
new file mode 100644
index 0000000..3de607c
--- /dev/null
+++ b/solr/core/src/test-files/solr/collection1/conf/bad-schema-default-operator.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<schema name="bad-schema-default-operator" version="1.6">
+  <fieldType name="string" class="solr.StrField"/>
+  <field name="id" type="string" indexed="true" stored="true" multiValued="false" required="false"/>
+  <uniqueKey>id</uniqueKey>
+  <!-- BEGIN BAD STUFF: not allowed anymore -->
+  <solrQueryParser defaultOperator="OR"/>
+  <!-- END BAD STUFF -->
+</schema>

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f3ac0c41/solr/core/src/test-files/solr/collection1/conf/solrconfig-minimal-version6.xml
----------------------------------------------------------------------
diff --git a/solr/core/src/test-files/solr/collection1/conf/solrconfig-minimal-version6.xml b/solr/core/src/test-files/solr/collection1/conf/solrconfig-minimal-version6.xml
new file mode 100644
index 0000000..7d69afe
--- /dev/null
+++ b/solr/core/src/test-files/solr/collection1/conf/solrconfig-minimal-version6.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" ?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- This is a "kitchen sink" config file that tests can use.
+     When writting a new test, feel free to add *new* items (plugins,
+     config options, etc...) as long as they don't break any existing
+     tests.  if you need to test something esoteric please add a new
+     "solrconfig-your-esoteric-purpose.xml" config file.
+
+     Note in particular that this test is used by MinimalSchemaTest so
+     Anything added to this file needs to work correctly even if there
+     is now uniqueKey or defaultSearch Field.
+  -->
+
+<config>
+
+  <dataDir>${solr.data.dir:}</dataDir>
+
+  <directoryFactory name="DirectoryFactory"
+                    class="${solr.directoryFactory:solr.NRTCachingDirectoryFactory}"/>
+  <schemaFactory class="ClassicIndexSchemaFactory"/>
+
+  <luceneMatchVersion>6.0.0</luceneMatchVersion>
+
+  <xi:include href="solrconfig.snippet.randomindexconfig.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
+
+  <updateHandler class="solr.DirectUpdateHandler2">
+    <commitWithin>
+      <softCommit>${solr.commitwithin.softcommit:true}</softCommit>
+    </commitWithin>
+
+  </updateHandler>
+  <requestHandler name="/select" class="solr.SearchHandler">
+    <lst name="defaults">
+      <str name="echoParams">explicit</str>
+      <str name="indent">true</str>
+      <str name="df">text</str>
+    </lst>
+
+  </requestHandler>
+
+</config>
+

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f3ac0c41/solr/core/src/test/org/apache/solr/schema/BadIndexSchemaTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/schema/BadIndexSchemaTest.java b/solr/core/src/test/org/apache/solr/schema/BadIndexSchemaTest.java
index 8d2f93a..fe1c647 100644
--- a/solr/core/src/test/org/apache/solr/schema/BadIndexSchemaTest.java
+++ b/solr/core/src/test/org/apache/solr/schema/BadIndexSchemaTest.java
@@ -127,5 +127,14 @@ public class BadIndexSchemaTest extends AbstractBadConfigTestBase {
     doTest("bad-schema-sim-default-does-not-exist.xml",
            "ft-does-not-exist");
   }
-  
+
+  public void testDefaultOperatorBanned() throws Exception {
+    doTest("bad-schema-default-operator.xml",
+           "default operator in schema (solrQueryParser/@defaultOperator) not supported");
+  }
+
+  public void testDefaultOperatorNotBannedForPre66() throws Exception {
+    initCore("solrconfig-minimal-version6.xml", "bad-schema-default-operator.xml");
+  }
+
 }