Apache Lucene open-source search software
SOLR-3682: Fail to parse schema.xml if uniqueKeyField is multivalued
Chris M. Hostetter8e7b2cf4aa84
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 37f12b2cffe..39a9ea0ddbb 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -34,6 +34,15 @@ Velocity 1.6.4 and Velocity Tools 2.0Apache UIMA 2.3.1Apache ZooKeeper 3.3.5+Upgrading from Solr 4.0.0-ALPHA+----------------------++Solr is now much more strict about requiring that the uniqueKeyField feature+(if used) must refer to a field which is not multiValued. If you upgrade from+an earlier version of Solr and see an error that your uniqueKeyField "can not+be configured to be multivalued" please add 'multiValued="false"' to the+<field /> declaration for your uniqueKeyField. See SOLR-3682 for more details.+Detailed Change List----------------------@@ -188,6 +197,8 @@ Other Changes* SOLR-3683: Improved error handling if an <analyzer> contains both anexplicit class attribute, as well as nested factories. (hossman)+* SOLR-3682: Fail to parse schema.xml if uniqueKeyField is multivalued (hossman)+================== 4.0.0-ALPHA ==================More information about this release, including any errata related to therelease notes, upgrade instructions, or other changes may be found online at:diff --git a/solr/core/src/java/org/apache/solr/schema/IndexSchema.java b/solr/core/src/java/org/apache/solr/schema/IndexSchema.javaindex 320902a70db..1767213a306 100644--- a/solr/core/src/java/org/apache/solr/schema/IndexSchema.java+++ b/solr/core/src/java/org/apache/solr/schema/IndexSchema.java@@ -499,7 +499,10 @@ public final class IndexSchema {log.error("uniqueKey is not stored - distributed search will not work");}if (uniqueKeyField.multiValued()) {- log.error("uniqueKey should not be multivalued");+ String msg = "uniqueKey field ("+uniqueKeyFieldName++ ") can not be configured to be multivalued";+ log.error(msg);+ throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, msg );}uniqueKeyFieldName=uniqueKeyField.getName();uniqueKeyFieldType=uniqueKeyField.getType();diff --git a/solr/core/src/test-files/solr/collection1/conf/bad-schema-uniquekey-multivalued.xml b/solr/core/src/test-files/solr/collection1/conf/bad-schema-uniquekey-multivalued.xmlnew file mode 100644index 00000000000..81ce319eb86--- /dev/null+++ b/solr/core/src/test-files/solr/collection1/conf/bad-schema-uniquekey-multivalued.xml@@ -0,0 +1,33 @@+<?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-uniquekey-multivalued" version="1.4">+ <types>+ <fieldType name="string" class="solr.StrField" multiValued="true"/>+ </types>++ <fields>+ <!-- BEGIN BAD STUFF: multiValued inherited from field type -->+ <field name="id" type="string" indexed="true" stored="true" />+ <!-- END BAD STUFF -->+ </fields>++ <defaultSearchField>id</defaultSearchField>+ <uniqueKey>id</uniqueKey>++</schema>diff --git a/solr/core/src/test/org/apache/solr/schema/BadIndexSchemaTest.java b/solr/core/src/test/org/apache/solr/schema/BadIndexSchemaTest.javaindex 79e9de8a8c7..91803f3de55 100644--- a/solr/core/src/test/org/apache/solr/schema/BadIndexSchemaTest.java+++ b/solr/core/src/test/org/apache/solr/schema/BadIndexSchemaTest.java@@ -62,6 +62,8 @@ public class BadIndexSchemaTest extends AbstractBadConfigTestBase {"can not be the dest of a copyField");doTest("bad-schema-uniquekey-uses-default.xml","can not be configured with a default value");+ doTest("bad-schema-uniquekey-multivalued.xml",+ "can not be configured to be multivalued");}public void testPerFieldtypeSimButNoSchemaSimFactory() throws Exception {diff --git a/solr/example/example-DIH/solr/db/conf/schema.xml b/solr/example/example-DIH/solr/db/conf/schema.xmlindex f110064d953..3a9c877e8a8 100644--- a/solr/example/example-DIH/solr/db/conf/schema.xml+++ b/solr/example/example-DIH/solr/db/conf/schema.xml@@ -259,7 +259,7 @@best performance.-->- <field name="id" type="string" indexed="true" stored="true" required="true" />+ <field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" /><field name="sku" type="textTight" indexed="true" stored="true" omitNorms="true"/><field name="name" type="text" indexed="true" stored="true"/><field name="nameSort" type="string" indexed="true" stored="false"/>diff --git a/solr/example/example-DIH/solr/rss/conf/schema.xml b/solr/example/example-DIH/solr/rss/conf/schema.xmlindex 0427c8e7257..cf1bcfac0b2 100644--- a/solr/example/example-DIH/solr/rss/conf/schema.xml+++ b/solr/example/example-DIH/solr/rss/conf/schema.xml@@ -291,7 +291,7 @@<field name="subject" type="text" indexed="true" stored="true" /><field name="title" type="text" indexed="true" stored="true" />- <field name="link" type="string" indexed="true" stored="true" />+ <field name="link" type="string" indexed="true" stored="true" multiValued="false" /><field name="description" type="html" indexed="true" stored="true" /><field name="creator" type="string" indexed="false" stored="true" /><field name="item-subject" type="string" indexed="true" stored="false" />diff --git a/solr/example/example-DIH/solr/solr/conf/schema.xml b/solr/example/example-DIH/solr/solr/conf/schema.xmlindex 678674fc63d..5a8143beb72 100644--- a/solr/example/example-DIH/solr/solr/conf/schema.xml+++ b/solr/example/example-DIH/solr/solr/conf/schema.xml@@ -259,7 +259,7 @@best performance.-->- <field name="id" type="string" indexed="true" stored="true" required="true" />+ <field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" /><field name="sku" type="textTight" indexed="true" stored="true" omitNorms="true"/><field name="name" type="text" indexed="true" stored="true"/><field name="nameSort" type="string" indexed="true" stored="false"/>diff --git a/solr/example/solr/collection1/conf/schema.xml b/solr/example/solr/collection1/conf/schema.xmlindex 7db0040d870..f6504e41912 100755--- a/solr/example/solr/collection1/conf/schema.xml+++ b/solr/example/solr/collection1/conf/schema.xml@@ -91,7 +91,7 @@trailing underscores (e.g. _version_) are reserved.-->- <field name="id" type="string" indexed="true" stored="true" required="true" />+ <field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" /><field name="sku" type="text_en_splitting_tight" indexed="true" stored="true" omitNorms="true"/><field name="name" type="text_general" indexed="true" stored="true"/><field name="manu" type="text_general" indexed="true" stored="true" omitNorms="true"/>