You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ho...@apache.org on 2017/06/09 18:41:48 UTC

[2/2] lucene-solr:branch_6x: SOLR-10829: Fixed IndexSchema to enforce that uniqueKey can not be Points based for correctness

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

(cherry picked from commit 8cd826f2936853d345c863e51c50eeaa9754a061)


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

Branch: refs/heads/branch_6x
Commit: 477eeea1ede3eac12328a57642f88cb6ea8994b8
Parents: 1fcbadc
Author: Chris Hostetter <ho...@apache.org>
Authored: Fri Jun 9 09:36:01 2017 -0700
Committer: Chris Hostetter <ho...@apache.org>
Committed: Fri Jun 9 11:40:18 2017 -0700

----------------------------------------------------------------------
 solr/CHANGES.txt                                |  2 ++
 .../org/apache/solr/schema/IndexSchema.java     |  8 ++++++
 .../conf/bad-schema-uniquekey-uses-points.xml   | 28 ++++++++++++++++++++
 .../apache/solr/schema/BadIndexSchemaTest.java  |  2 ++
 4 files changed, 40 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/477eeea1/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 6327f2b..cc44ccb 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -108,6 +108,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)

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/477eeea1/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 199a088..7563695 100644
--- a/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
+++ b/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
@@ -584,6 +584,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();
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/477eeea1/solr/core/src/test-files/solr/collection1/conf/bad-schema-uniquekey-uses-points.xml
----------------------------------------------------------------------
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 0000000..ac4fd9c
--- /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>

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/477eeea1/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 13ef0e9..81f8a42 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 {