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 2011/07/24 22:09:44 UTC
svn commit: r1150478 - in /lucene/dev/trunk/solr: ./
core/src/java/org/apache/solr/schema/ core/src/test-files/solr/conf/
core/src/test/org/apache/solr/schema/
Author: hossman
Date: Sun Jul 24 20:09:43 2011
New Revision: 1150478
URL: http://svn.apache.org/viewvc?rev=1150478&view=rev
Log:
SOLR-2669: Fix backwards validation logic in SchemaField.calcProps
Added:
lucene/dev/trunk/solr/core/src/test-files/solr/conf/bad-schema-not-indexed-but-norms.xml (with props)
lucene/dev/trunk/solr/core/src/test-files/solr/conf/bad-schema-not-indexed-but-pos.xml (with props)
lucene/dev/trunk/solr/core/src/test-files/solr/conf/bad-schema-not-indexed-but-tf.xml (with props)
lucene/dev/trunk/solr/core/src/test-files/solr/conf/bad-schema-omit-tf-but-not-pos.xml (with props)
Modified:
lucene/dev/trunk/solr/CHANGES.txt
lucene/dev/trunk/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
lucene/dev/trunk/solr/core/src/java/org/apache/solr/schema/SchemaField.java
lucene/dev/trunk/solr/core/src/test-files/solr/conf/schema.xml
lucene/dev/trunk/solr/core/src/test/org/apache/solr/schema/BadIndexSchemaTest.java
Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1150478&r1=1150477&r2=1150478&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Sun Jul 24 20:09:43 2011
@@ -288,6 +288,19 @@ Upgrading from Solr 3.3
before the master. If the master were to be updated first, the older
searchers would not be able to read the new index format.
+* Previous versions of Solr silently allow and ignore some contradictory
+ properties specified in schema.xml. For example:
+ - indexed="false" omitNorms="false"
+ - indexed="false" omitTermFreqAndPositions="false"
+ Field property validation has now been fixed, to ensure that
+ contradictions like these now generate error messages. If users
+ have existing schemas that generate one of these new "conflicting
+ 'false' field options for non-indexed field" error messages the
+ conflicting "omit*" properties can safely be removed, or changed to
+ "true" for consistent behavior with previous Solr versions. This
+ situation has now been fixed to cause an error on startup when these
+ contradictory options. See SOLR-2669.
+
New Features
----------------------
@@ -378,6 +391,8 @@ Bug Fixes
"start" parameter was not honored and the documents returned were
0 through start+offset. (Markus Jelsma, yonik)
+* SOLR-2669: Fix backwards validation of field properties in
+ SchemaField.calcProps (hossman)
Other Changes
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/schema/IndexSchema.java?rev=1150478&r1=1150477&r2=1150478&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/schema/IndexSchema.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/schema/IndexSchema.java Sun Jul 24 20:09:43 2011
@@ -577,7 +577,7 @@ public final class IndexSchema {
} catch(Exception e) {
// unexpected exception...
SolrConfig.severeErrors.add( e );
- throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,"Schema Parsing Failed",e,false);
+ throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,"Schema Parsing Failed: " + e.getMessage(), e,false);
}
// create the field analyzers
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/schema/SchemaField.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/schema/SchemaField.java?rev=1150478&r1=1150477&r2=1150478&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/schema/SchemaField.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/schema/SchemaField.java Sun Jul 24 20:09:43 2011
@@ -226,20 +226,27 @@ public final class SchemaField extends F
}
if (on(falseProps,INDEXED)) {
- int pp = (INDEXED | OMIT_NORMS | OMIT_TF_POSITIONS | OMIT_POSITIONS
+ int pp = (INDEXED
| STORE_TERMVECTORS | STORE_TERMPOSITIONS | STORE_TERMOFFSETS
| SORT_MISSING_FIRST | SORT_MISSING_LAST);
if (on(pp,trueProps)) {
- throw new RuntimeException("SchemaField: " + name + " conflicting indexed field options:" + props);
+ throw new RuntimeException("SchemaField: " + name + " conflicting 'true' field options for non-indexed field:" + props);
+ }
+ p &= ~pp;
+ }
+ if (on(falseProps,INDEXED)) {
+ int pp = (OMIT_NORMS | OMIT_TF_POSITIONS | OMIT_POSITIONS);
+ if (on(pp,falseProps)) {
+ throw new RuntimeException("SchemaField: " + name + " conflicting 'false' field options for non-indexed field:" + props);
}
p &= ~pp;
}
- if (on(falseProps,OMIT_TF_POSITIONS)) {
+ if (on(trueProps,OMIT_TF_POSITIONS)) {
int pp = (OMIT_POSITIONS | OMIT_TF_POSITIONS);
- if (on(pp, trueProps)) {
- throw new RuntimeException("SchemaField: " + name + " conflicting indexed field options:" + props);
+ if (on(pp, falseProps)) {
+ throw new RuntimeException("SchemaField: " + name + " conflicting tf and position field options:" + props);
}
p &= ~pp;
}
Added: lucene/dev/trunk/solr/core/src/test-files/solr/conf/bad-schema-not-indexed-but-norms.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test-files/solr/conf/bad-schema-not-indexed-but-norms.xml?rev=1150478&view=auto
==============================================================================
--- lucene/dev/trunk/solr/core/src/test-files/solr/conf/bad-schema-not-indexed-but-norms.xml (added)
+++ lucene/dev/trunk/solr/core/src/test-files/solr/conf/bad-schema-not-indexed-but-norms.xml Sun Jul 24 20:09:43 2011
@@ -0,0 +1,40 @@
+<?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-not-indexed-but-norms" version="1.0">
+ <types>
+ <fieldType name="string" class="solr.StrField"/>
+ </types>
+
+ <fields>
+ <field name="id" type="string" indexed="true" stored="true" multiValued="false" required="false"/>
+
+ <field name="signatureField" type="string" indexed="true" stored="false"/>
+
+ <!-- BEGIN BAD STUFF -->
+ <field name="bad_field" type="string" indexed="false" omitNorms="false" />
+ <!-- END BAD STUFF -->
+
+ <dynamicField name="*_sS" type="string" indexed="false" stored="true"/>
+
+ </fields>
+
+ <defaultSearchField>id</defaultSearchField>
+ <uniqueKey>id</uniqueKey>
+
+</schema>
Added: lucene/dev/trunk/solr/core/src/test-files/solr/conf/bad-schema-not-indexed-but-pos.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test-files/solr/conf/bad-schema-not-indexed-but-pos.xml?rev=1150478&view=auto
==============================================================================
--- lucene/dev/trunk/solr/core/src/test-files/solr/conf/bad-schema-not-indexed-but-pos.xml (added)
+++ lucene/dev/trunk/solr/core/src/test-files/solr/conf/bad-schema-not-indexed-but-pos.xml Sun Jul 24 20:09:43 2011
@@ -0,0 +1,40 @@
+<?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-not-indexed-but-pos" version="1.0">
+ <types>
+ <fieldType name="string" class="solr.StrField"/>
+ </types>
+
+ <fields>
+ <field name="id" type="string" indexed="true" stored="true" multiValued="false" required="false"/>
+
+ <field name="signatureField" type="string" indexed="true" stored="false"/>
+
+ <!-- BEGIN BAD STUFF -->
+ <field name="bad_field" type="string" indexed="false" omitPositions="false" />
+ <!-- END BAD STUFF -->
+
+ <dynamicField name="*_sS" type="string" indexed="false" stored="true"/>
+
+ </fields>
+
+ <defaultSearchField>id</defaultSearchField>
+ <uniqueKey>id</uniqueKey>
+
+</schema>
Added: lucene/dev/trunk/solr/core/src/test-files/solr/conf/bad-schema-not-indexed-but-tf.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test-files/solr/conf/bad-schema-not-indexed-but-tf.xml?rev=1150478&view=auto
==============================================================================
--- lucene/dev/trunk/solr/core/src/test-files/solr/conf/bad-schema-not-indexed-but-tf.xml (added)
+++ lucene/dev/trunk/solr/core/src/test-files/solr/conf/bad-schema-not-indexed-but-tf.xml Sun Jul 24 20:09:43 2011
@@ -0,0 +1,40 @@
+<?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-not-indexed-but-tf" version="1.0">
+ <types>
+ <fieldType name="string" class="solr.StrField"/>
+ </types>
+
+ <fields>
+ <field name="id" type="string" indexed="true" stored="true" multiValued="false" required="false"/>
+
+ <field name="signatureField" type="string" indexed="true" stored="false"/>
+
+ <!-- BEGIN BAD STUFF -->
+ <field name="bad_field" type="string" indexed="false" omitTermFreqAndPositions="false" />
+ <!-- END BAD STUFF -->
+
+ <dynamicField name="*_sS" type="string" indexed="false" stored="true"/>
+
+ </fields>
+
+ <defaultSearchField>id</defaultSearchField>
+ <uniqueKey>id</uniqueKey>
+
+</schema>
Added: lucene/dev/trunk/solr/core/src/test-files/solr/conf/bad-schema-omit-tf-but-not-pos.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test-files/solr/conf/bad-schema-omit-tf-but-not-pos.xml?rev=1150478&view=auto
==============================================================================
--- lucene/dev/trunk/solr/core/src/test-files/solr/conf/bad-schema-omit-tf-but-not-pos.xml (added)
+++ lucene/dev/trunk/solr/core/src/test-files/solr/conf/bad-schema-omit-tf-but-not-pos.xml Sun Jul 24 20:09:43 2011
@@ -0,0 +1,41 @@
+<?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-omit-tf-but-not-pos" version="1.0">
+ <types>
+ <fieldType name="string" class="solr.StrField"/>
+ </types>
+
+ <fields>
+ <field name="id" type="string" indexed="true" stored="true" multiValued="false" required="false"/>
+
+ <field name="signatureField" type="string" indexed="true" stored="false"/>
+
+ <!-- BEGIN BAD STUFF -->
+ <field name="bad_field" type="string" indexed="true"
+ omitTermFreqAndPositions="true" omitPositions="false" />
+ <!-- END BAD STUFF -->
+
+ <dynamicField name="*_sS" type="string" indexed="false" stored="true"/>
+
+ </fields>
+
+ <defaultSearchField>id</defaultSearchField>
+ <uniqueKey>id</uniqueKey>
+
+</schema>
Modified: lucene/dev/trunk/solr/core/src/test-files/solr/conf/schema.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test-files/solr/conf/schema.xml?rev=1150478&r1=1150477&r2=1150478&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test-files/solr/conf/schema.xml (original)
+++ lucene/dev/trunk/solr/core/src/test-files/solr/conf/schema.xml Sun Jul 24 20:09:43 2011
@@ -481,6 +481,24 @@
<field name="test_posofftv" type="text" termVectors="true"
termPositions="true" termOffsets="true"/>
+ <!-- test valid combinations of indexed settings,
+ see also BadIndexSchemaTest -->
+ <!-- indexed=false should not prevent omit___=true -->
+ <field name="pint_i_norm" type="pint" omitNorms="true"
+ indexed="false" />
+ <field name="pint_i_tf" type="pint" omitOmitTermFreqAndPositions="true"
+ indexed="false" />
+ <field name="pint_i_pos" type="pint" omitPositions="true"
+ indexed="false" />
+ <field name="pint_i_all" type="pint"
+ indexed="false"
+ omitNorms="true"
+ omitOmitTermFreqAndPositions="true"
+ omitPositions="true" />
+ <!-- omitOmitTermFreqAndPositions=false and omitPositions=true are ok -->
+ <field name="pint_tf_pos" type="pint" indexed="true"
+ omitOmitTermFreqAndPositions="false" omitPositions="true" />
+
<!-- test highlit field settings -->
<field name="test_hlt" type="highlittext" indexed="true" compressed="true"/>
<field name="test_hlt_off" type="highlittext" indexed="true" compressed="false"/>
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/schema/BadIndexSchemaTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/schema/BadIndexSchemaTest.java?rev=1150478&r1=1150477&r2=1150478&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/schema/BadIndexSchemaTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/schema/BadIndexSchemaTest.java Sun Jul 24 20:09:43 2011
@@ -49,6 +49,14 @@ public class BadIndexSchemaTest extends
}
@Test
+ public void testSevereErrorsForInvalidFieldOptions() throws Exception {
+ 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-pos.xml", "bad_field");
+ doTest("bad-schema-omit-tf-but-not-pos.xml", "bad_field");
+ }
+
+ @Test
public void testSevereErrorsForDuplicateFields() throws Exception {
doTest("bad-schema-dup-field.xml", "fAgain");
}