Skip to content

Apache Lucene open-source search software

SOLR-10829: Fixed IndexSchema to enforce that uniqueKey can not be Points based for correctness

Chris Hostetter8cd826f29368
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index dc17616213e..e5eb0c19755 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -348,6 +348,8 @@ Bug Fixes
* SOLR-10137: Ensure that ConfigSets created via API are mutable. (Hrishikesh via Mark Miller)
+* SOLR-10829: Fixed IndexSchema to enforce that uniqueKey can not be Points based for correctness (hossman)
+
Optimizations
----------------------
* SOLR-10634: JSON Facet API: When a field/terms facet will retrieve all buckets (i.e. limit:-1)
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 04f64d5d7a3..463df3ee681 100644
--- a/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
+++ b/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
@@ -534,6 +534,14 @@ public class IndexSchema {
log.error(msg);
throw new SolrException(ErrorCode.SERVER_ERROR, msg);
}
+
+ if (uniqueKeyField.getType().isPointField()) {
+ String msg = UNIQUE_KEY + " field ("+uniqueKeyFieldName+
+ ") can not be configured to use a Points based FieldType: " + uniqueKeyField.getType().getTypeName();
+ log.error(msg);
+ throw new 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-uses-points.xml b/solr/core/src/test-files/solr/collection1/conf/bad-schema-uniquekey-uses-points.xml
new file mode 100644
index 00000000000..ac4fd9c4a2d
--- /dev/null
+++ b/solr/core/src/test-files/solr/collection1/conf/bad-schema-uniquekey-uses-points.xml
@@ -0,0 +1,28 @@
+<?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-uses-points" version="1.4">
+ <fieldType name="bad" class="solr.IntPointField"/>
+
+ <!-- BEGIN BAD STUFF -->
+ <field name="id" type="bad" indexed="true" stored="true" />
+ <!-- END BAD STUFF -->
+
+ <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.java
index 2d5adf993d0..5545d959026 100644
--- a/solr/core/src/test/org/apache/solr/schema/BadIndexSchemaTest.java
+++ b/solr/core/src/test/org/apache/solr/schema/BadIndexSchemaTest.java
@@ -65,6 +65,8 @@ public class BadIndexSchemaTest extends AbstractBadConfigTestBase {
"can not be configured with a default value");
doTest("bad-schema-uniquekey-multivalued.xml",
"can not be configured to be multivalued");
+ doTest("bad-schema-uniquekey-uses-points.xml",
+ "can not be configured to use a Points based FieldType");
}
public void testMultivaluedCurrency() throws Exception {