mirror of https://github.com/apache/lucene.git
SOLR-2796: uniqueKey field can no longer be populated via <copyField/> or <field default=...>. Also corrected CHANGES.txt entry for related SOLR-3495
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1345376 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7d87c740ee
commit
f7707d7d91
|
@ -89,6 +89,14 @@ Upgrading from Solr 3.6-dev
|
||||||
paths have been fixed to be resolved against the data dir. See the example
|
paths have been fixed to be resolved against the data dir. See the example
|
||||||
solrconfig.xml and SOLR-1258 for more details.
|
solrconfig.xml and SOLR-1258 for more details.
|
||||||
|
|
||||||
|
* Due to low level changes to support SolrCloud, the uniqueKey field can no
|
||||||
|
longer be populated via <copyField/> or <field default=...> in the
|
||||||
|
schema.xml. Users wishing to have Solr automaticly generate a uniqueKey
|
||||||
|
value when adding documents should instead use an instance of
|
||||||
|
solr.UUIDUpdateProcessorFactory in their update processor chain. See
|
||||||
|
SOLR-2796 for more details.
|
||||||
|
|
||||||
|
|
||||||
Detailed Change List
|
Detailed Change List
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
@ -320,7 +328,7 @@ New Features
|
||||||
prior "FieldName^boost" syntax is still accepted. In such cases the value on the
|
prior "FieldName^boost" syntax is still accepted. In such cases the value on the
|
||||||
"ps" parameter serves as the default slop. (Ron Mayer via James Dyer)
|
"ps" parameter serves as the default slop. (Ron Mayer via James Dyer)
|
||||||
|
|
||||||
* SOLR-2796: New UpdateProcessors have been added to create default values for
|
* SOLR-3495: New UpdateProcessors have been added to create default values for
|
||||||
configured fields. These works similarly to the <field default="..."/>
|
configured fields. These works similarly to the <field default="..."/>
|
||||||
option in schema.xml, but are applied in the UpdateProcessorChain, so they
|
option in schema.xml, but are applied in the UpdateProcessorChain, so they
|
||||||
may be used prior to other UpdateProcessors, or to generate a uniqueKey field
|
may be used prior to other UpdateProcessors, or to generate a uniqueKey field
|
||||||
|
@ -609,6 +617,9 @@ Other Changes
|
||||||
* SOLR-3083: JMX beans now report Numbers as numeric values rather then String
|
* SOLR-3083: JMX beans now report Numbers as numeric values rather then String
|
||||||
(Tagged Siteops, Greg Bowyer via ryan)
|
(Tagged Siteops, Greg Bowyer via ryan)
|
||||||
|
|
||||||
|
* SOLR-2796: Due to low level changes to support SolrCloud, the uniqueKey
|
||||||
|
field can no longer be populated via <copyField/> or <field default=...>
|
||||||
|
in the schema.xml.
|
||||||
|
|
||||||
Documentation
|
Documentation
|
||||||
----------------------
|
----------------------
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
* this work for additional information regarding copyright ownership.
|
* this work for additional information regarding copyright ownership.
|
||||||
|
@ -465,6 +465,14 @@ public final class IndexSchema {
|
||||||
log.warn("no uniqueKey specified in schema.");
|
log.warn("no uniqueKey specified in schema.");
|
||||||
} else {
|
} else {
|
||||||
uniqueKeyField=getIndexedField(node.getNodeValue().trim());
|
uniqueKeyField=getIndexedField(node.getNodeValue().trim());
|
||||||
|
if (null != uniqueKeyField.getDefaultValue()) {
|
||||||
|
String msg = "uniqueKey field ("+uniqueKeyFieldName+
|
||||||
|
") can not be configured with a default value ("+
|
||||||
|
uniqueKeyField.getDefaultValue()+")";
|
||||||
|
log.error(msg);
|
||||||
|
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, msg );
|
||||||
|
}
|
||||||
|
|
||||||
if (!uniqueKeyField.stored()) {
|
if (!uniqueKeyField.stored()) {
|
||||||
log.error("uniqueKey is not stored - distributed search will not work");
|
log.error("uniqueKey is not stored - distributed search will not work");
|
||||||
}
|
}
|
||||||
|
@ -507,6 +515,14 @@ public final class IndexSchema {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dest.equals(uniqueKeyFieldName)) {
|
||||||
|
String msg = "uniqueKey field ("+uniqueKeyFieldName+
|
||||||
|
") can not be the dest of a copyField (src="+source+")";
|
||||||
|
log.error(msg);
|
||||||
|
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, msg);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
registerCopyField(source, dest, maxCharsInt);
|
registerCopyField(source, dest, maxCharsInt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -517,6 +533,8 @@ public final class IndexSchema {
|
||||||
entry.getValue()+")");
|
entry.getValue()+")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Run the callbacks on SchemaAware now that everything else is done
|
//Run the callbacks on SchemaAware now that everything else is done
|
||||||
for (SchemaAware aware : schemaAware) {
|
for (SchemaAware aware : schemaAware) {
|
||||||
aware.inform(this);
|
aware.inform(this);
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?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-is-copyfield-dest" version="1.4">
|
||||||
|
<types>
|
||||||
|
<fieldType name="string" class="solr.StrField"/>
|
||||||
|
</types>
|
||||||
|
|
||||||
|
<fields>
|
||||||
|
<field name="id" type="string" indexed="true" stored="true"/>
|
||||||
|
<field name="XXX" type="string" indexed="true" stored="true"/>
|
||||||
|
|
||||||
|
<!-- BEGIN BAD STUFF -->
|
||||||
|
<copyField source="XXX" dest="id"/>
|
||||||
|
<!-- END BAD STUFF -->
|
||||||
|
</fields>
|
||||||
|
|
||||||
|
<defaultSearchField>id</defaultSearchField>
|
||||||
|
<uniqueKey>id</uniqueKey>
|
||||||
|
|
||||||
|
</schema>
|
|
@ -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-uses-default" version="1.4">
|
||||||
|
<types>
|
||||||
|
<fieldType name="string" class="solr.StrField"/>
|
||||||
|
</types>
|
||||||
|
|
||||||
|
<fields>
|
||||||
|
<!-- BEGIN BAD STUFF -->
|
||||||
|
<field name="id" type="string" indexed="true" stored="true" default="XXX"/>
|
||||||
|
<!-- END BAD STUFF -->
|
||||||
|
</fields>
|
||||||
|
|
||||||
|
<defaultSearchField>id</defaultSearchField>
|
||||||
|
<uniqueKey>id</uniqueKey>
|
||||||
|
|
||||||
|
</schema>
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
* this work for additional information regarding copyright ownership.
|
* this work for additional information regarding copyright ownership.
|
||||||
|
@ -38,7 +38,8 @@ public class BadIndexSchemaTest extends SolrTestCaseJ4 {
|
||||||
// short circuit out if we found what we expected
|
// short circuit out if we found what we expected
|
||||||
if (-1 != e.getMessage().indexOf(errString)) return;
|
if (-1 != e.getMessage().indexOf(errString)) return;
|
||||||
// Test the cause too in case the expected error is wrapped
|
// Test the cause too in case the expected error is wrapped
|
||||||
if (-1 != e.getCause().getMessage().indexOf(errString)) return;
|
if (null != e.getCause() &&
|
||||||
|
-1 != e.getCause().getMessage().indexOf(errString)) return;
|
||||||
|
|
||||||
// otherwise, rethrow it, possibly completley unrelated
|
// otherwise, rethrow it, possibly completley unrelated
|
||||||
throw new SolrException
|
throw new SolrException
|
||||||
|
@ -50,7 +51,6 @@ public class BadIndexSchemaTest extends SolrTestCaseJ4 {
|
||||||
fail("Did not encounter any exception from: " + schema);
|
fail("Did not encounter any exception from: " + schema);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSevereErrorsForInvalidFieldOptions() throws Exception {
|
public void testSevereErrorsForInvalidFieldOptions() throws Exception {
|
||||||
doTest("bad-schema-not-indexed-but-norms.xml", "bad_field");
|
doTest("bad-schema-not-indexed-but-norms.xml", "bad_field");
|
||||||
doTest("bad-schema-not-indexed-but-tf.xml", "bad_field");
|
doTest("bad-schema-not-indexed-but-tf.xml", "bad_field");
|
||||||
|
@ -58,29 +58,32 @@ public class BadIndexSchemaTest extends SolrTestCaseJ4 {
|
||||||
doTest("bad-schema-omit-tf-but-not-pos.xml", "bad_field");
|
doTest("bad-schema-omit-tf-but-not-pos.xml", "bad_field");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSevereErrorsForDuplicateFields() throws Exception {
|
public void testSevereErrorsForDuplicateFields() throws Exception {
|
||||||
doTest("bad-schema-dup-field.xml", "fAgain");
|
doTest("bad-schema-dup-field.xml", "fAgain");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSevereErrorsForDuplicateDynamicField() throws Exception {
|
public void testSevereErrorsForDuplicateDynamicField() throws Exception {
|
||||||
doTest("bad-schema-dup-dynamicField.xml", "_twice");
|
doTest("bad-schema-dup-dynamicField.xml", "_twice");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSevereErrorsForDuplicateFieldType() throws Exception {
|
public void testSevereErrorsForDuplicateFieldType() throws Exception {
|
||||||
doTest("bad-schema-dup-fieldType.xml", "ftAgain");
|
doTest("bad-schema-dup-fieldType.xml", "ftAgain");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSevereErrorsForUnexpectedAnalyzer() throws Exception {
|
public void testSevereErrorsForUnexpectedAnalyzer() throws Exception {
|
||||||
doTest("bad-schema-nontext-analyzer.xml", "StrField (bad_type)");
|
doTest("bad-schema-nontext-analyzer.xml", "StrField (bad_type)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testBadExternalFileField() throws Exception {
|
public void testBadExternalFileField() throws Exception {
|
||||||
doTest("bad-schema-external-filefield.xml",
|
doTest("bad-schema-external-filefield.xml",
|
||||||
"Only float and pfloat");
|
"Only float and pfloat");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testUniqueKeyRules() throws Exception {
|
||||||
|
doTest("bad-schema-uniquekey-is-copyfield-dest.xml",
|
||||||
|
"can not be the dest of a copyField");
|
||||||
|
doTest("bad-schema-uniquekey-uses-default.xml",
|
||||||
|
"can not be configured with a default value");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue