mirror of https://github.com/apache/lucene.git
SOLR-2669: Fix backwards validation logic in SchemaField.calcProps
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1150478 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
49075985fb
commit
7c1a58f72d
|
@ -288,6 +288,19 @@ Upgrading from Solr 3.3
|
||||||
before the master. If the master were to be updated first, the older
|
before the master. If the master were to be updated first, the older
|
||||||
searchers would not be able to read the new index format.
|
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
|
New Features
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
@ -378,6 +391,8 @@ Bug Fixes
|
||||||
"start" parameter was not honored and the documents returned were
|
"start" parameter was not honored and the documents returned were
|
||||||
0 through start+offset. (Markus Jelsma, yonik)
|
0 through start+offset. (Markus Jelsma, yonik)
|
||||||
|
|
||||||
|
* SOLR-2669: Fix backwards validation of field properties in
|
||||||
|
SchemaField.calcProps (hossman)
|
||||||
|
|
||||||
|
|
||||||
Other Changes
|
Other Changes
|
||||||
|
|
|
@ -577,7 +577,7 @@ public final class IndexSchema {
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
// unexpected exception...
|
// unexpected exception...
|
||||||
SolrConfig.severeErrors.add( e );
|
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
|
// create the field analyzers
|
||||||
|
|
|
@ -226,20 +226,27 @@ public final class SchemaField extends FieldProperties {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (on(falseProps,INDEXED)) {
|
if (on(falseProps,INDEXED)) {
|
||||||
int pp = (INDEXED | OMIT_NORMS | OMIT_TF_POSITIONS | OMIT_POSITIONS
|
int pp = (INDEXED
|
||||||
| STORE_TERMVECTORS | STORE_TERMPOSITIONS | STORE_TERMOFFSETS
|
| STORE_TERMVECTORS | STORE_TERMPOSITIONS | STORE_TERMOFFSETS
|
||||||
| SORT_MISSING_FIRST | SORT_MISSING_LAST);
|
| SORT_MISSING_FIRST | SORT_MISSING_LAST);
|
||||||
if (on(pp,trueProps)) {
|
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;
|
p &= ~pp;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (on(falseProps,OMIT_TF_POSITIONS)) {
|
if (on(trueProps,OMIT_TF_POSITIONS)) {
|
||||||
int pp = (OMIT_POSITIONS | OMIT_TF_POSITIONS);
|
int pp = (OMIT_POSITIONS | OMIT_TF_POSITIONS);
|
||||||
if (on(pp, trueProps)) {
|
if (on(pp, falseProps)) {
|
||||||
throw new RuntimeException("SchemaField: " + name + " conflicting indexed field options:" + props);
|
throw new RuntimeException("SchemaField: " + name + " conflicting tf and position field options:" + props);
|
||||||
}
|
}
|
||||||
p &= ~pp;
|
p &= ~pp;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -481,6 +481,24 @@
|
||||||
<field name="test_posofftv" type="text" termVectors="true"
|
<field name="test_posofftv" type="text" termVectors="true"
|
||||||
termPositions="true" termOffsets="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 -->
|
<!-- test highlit field settings -->
|
||||||
<field name="test_hlt" type="highlittext" indexed="true" compressed="true"/>
|
<field name="test_hlt" type="highlittext" indexed="true" compressed="true"/>
|
||||||
<field name="test_hlt_off" type="highlittext" indexed="true" compressed="false"/>
|
<field name="test_hlt_off" type="highlittext" indexed="true" compressed="false"/>
|
||||||
|
|
|
@ -48,6 +48,14 @@ 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 {
|
||||||
|
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
|
@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");
|
||||||
|
|
Loading…
Reference in New Issue