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/05 10:31:55 UTC
lucene-solr:branch_6x: SOLR-10587: Ban defaultSearchField in schema
for luceneMatchVersion =>6.6.0
Repository: lucene-solr
Updated Branches:
refs/heads/branch_6x 2a9f8c5f3 -> d2ea33d76
SOLR-10587: Ban defaultSearchField 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/d2ea33d7
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/d2ea33d7
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/d2ea33d7
Branch: refs/heads/branch_6x
Commit: d2ea33d7687f38894e03217e076e002dbfe66b76
Parents: 2a9f8c5
Author: Jan Høydahl <ja...@apache.org>
Authored: Fri May 5 12:31:44 2017 +0200
Committer: Jan Høydahl <ja...@apache.org>
Committed: Fri May 5 12:31:44 2017 +0200
----------------------------------------------------------------------
solr/CHANGES.txt | 6 +++++
.../org/apache/solr/schema/IndexSchema.java | 14 +++++++++--
.../conf/bad-schema-defaultsearchfield.xml | 26 ++++++++++++++++++++
.../apache/solr/schema/BadIndexSchemaTest.java | 7 ++++++
4 files changed, 51 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d2ea33d7/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index e59f03f..9a77598 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -43,6 +43,10 @@ Upgrade Notes
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.
+* Setting <defaultSearchField> 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 "df" parameter on the request instead. For more details, see SOLR-10587.
+
Detailed Change List
----------------------
New Features
@@ -245,6 +249,8 @@ Other Changes
* SOLR-7041: Cutover tests to using 'q.op' and 'df' instead of schema 'defaultOperator' and 'defaultSearchField' (janhoy)
+* SOLR-10587: Ban defaultSearchField in schema for luceneMatchVersion =>6.6.0 (Jason Gerlowski, janhoy)
+
================== 6.5.1 ==================
Bug Fixes
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d2ea33d7/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 5e9e87b..199a088 100644
--- a/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
+++ b/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
@@ -528,6 +528,7 @@ public class IndexSchema {
if (node==null) {
log.debug("no default search field specified in schema.");
} else {
+ checkVersionCompatibilityForDefaultSearchField();
defaultSearchFieldName=node.getNodeValue().trim();
// throw exception if specified, but not found or not indexed
if (defaultSearchFieldName!=null) {
@@ -537,8 +538,7 @@ public class IndexSchema {
throw new SolrException(ErrorCode.SERVER_ERROR, msg);
}
}
- log.warn("[{}] default search field in schema is {}. WARNING: Deprecated, please use 'df' on request instead.",
- coreName, defaultSearchFieldName);
+ log.info("[{}] default search field in schema is {}.", coreName, defaultSearchFieldName);
}
// /schema/solrQueryParser/@defaultOperator
@@ -617,6 +617,16 @@ public class IndexSchema {
log.info("Loaded schema {}/{} with uniqueid field {}", name, version, uniqueKeyFieldName);
}
+
+ private void checkVersionCompatibilityForDefaultSearchField() {
+ log.warn("'defaultSearchField' is deprecated, please use 'df' on request instead.");
+ if (getDefaultLuceneMatchVersion().onOrAfter(Version.LUCENE_6_6_0)) {
+ final String msg = "defaultSearchField has been deprecated and is incompatible with " +
+ "configs with luceneMatchVersion >= 6.6.0. Use 'df' on requests instead.";
+ log.error(msg);
+ throw new SolrException(ErrorCode.SERVER_ERROR, msg);
+ }
+ }
private String getCoreName(String defaultVal) {
if (loader != null && loader.getCoreProperties() != null) {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d2ea33d7/solr/core/src/test-files/solr/collection1/conf/bad-schema-defaultsearchfield.xml
----------------------------------------------------------------------
diff --git a/solr/core/src/test-files/solr/collection1/conf/bad-schema-defaultsearchfield.xml b/solr/core/src/test-files/solr/collection1/conf/bad-schema-defaultsearchfield.xml
new file mode 100644
index 0000000..9567e30
--- /dev/null
+++ b/solr/core/src/test-files/solr/collection1/conf/bad-schema-defaultsearchfield.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-defaultsearchfield" 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 -->
+ <defaultSearchField>id</defaultSearchField>
+ <!-- END BAD STUFF -->
+</schema>
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d2ea33d7/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 fe1c647..1d4a4f5 100644
--- a/solr/core/src/test/org/apache/solr/schema/BadIndexSchemaTest.java
+++ b/solr/core/src/test/org/apache/solr/schema/BadIndexSchemaTest.java
@@ -137,4 +137,11 @@ public class BadIndexSchemaTest extends AbstractBadConfigTestBase {
initCore("solrconfig-minimal-version6.xml", "bad-schema-default-operator.xml");
}
+ public void testSchemaWithDefaultSearchField() throws Exception {
+ doTest("bad-schema-defaultsearchfield.xml", "defaultSearchField");
+ }
+
+ public void testDefaultSearchFieldNotBannedForPre66() throws Exception {
+ initCore("solrconfig-minimal-version6.xml", "bad-schema-defaultsearchfield.xml");
+ }
}