diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 53bb4409aa5..d73c34a5a2b 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -118,6 +118,8 @@ Bug Fixes * SOLR-4650: copyField doesn't work with source globs that don't match any explicit or dynamic fields. This regression was introduced in Solr 4.2. (Daniel Collins, Steve Rowe) + +* SOLR-4641: Schema now throws exception on illegal field parameters. (Robert Muir) Optimizations ---------------------- diff --git a/solr/contrib/clustering/src/test-files/clustering/solr/collection1/conf/schema.xml b/solr/contrib/clustering/src/test-files/clustering/solr/collection1/conf/schema.xml index 9afe1f086eb..1804e680bc8 100644 --- a/solr/contrib/clustering/src/test-files/clustering/solr/collection1/conf/schema.xml +++ b/solr/contrib/clustering/src/test-files/clustering/solr/collection1/conf/schema.xml @@ -265,9 +265,6 @@ type: mandatory - the name of a previously defined type from the section indexed: true if this field should be indexed (searchable or sortable) stored: true if this field should be retrievable - compressed: [false] if this field should be stored using gzip compression - (this will only apply if the field type is compressable; among - the standard field types, only TextField and StrField are) multiValued: true if this field may contain multiple values per document omitNorms: (expert) set to true to omit the norms associated with this field (this disables length normalization and index-time diff --git a/solr/contrib/dataimporthandler/src/test-files/dih/solr/collection1/conf/dataimport-solr_id-schema.xml b/solr/contrib/dataimporthandler/src/test-files/dih/solr/collection1/conf/dataimport-solr_id-schema.xml index e789b05ec47..7bfd6c2e046 100644 --- a/solr/contrib/dataimporthandler/src/test-files/dih/solr/collection1/conf/dataimport-solr_id-schema.xml +++ b/solr/contrib/dataimporthandler/src/test-files/dih/solr/collection1/conf/dataimport-solr_id-schema.xml @@ -246,9 +246,6 @@ type: mandatory - the name of a previously defined type from the section indexed: true if this field should be indexed (searchable or sortable) stored: true if this field should be retrievable - compressed: [false] if this field should be stored using gzip compression - (this will only apply if the field type is compressable; among - the standard field types, only TextField and StrField are) multiValued: true if this field may contain multiple values per document omitNorms: (expert) set to true to omit the norms associated with this field (this disables length normalization and index-time diff --git a/solr/contrib/extraction/src/test-files/extraction/solr/collection1/conf/schema.xml b/solr/contrib/extraction/src/test-files/extraction/solr/collection1/conf/schema.xml index 6bf238bcf90..a08d698d207 100644 --- a/solr/contrib/extraction/src/test-files/extraction/solr/collection1/conf/schema.xml +++ b/solr/contrib/extraction/src/test-files/extraction/solr/collection1/conf/schema.xml @@ -354,8 +354,8 @@ termPositions="true" termOffsets="true"/> - - + + diff --git a/solr/contrib/uima/src/test-files/uima/solr/collection1/conf/schema.xml b/solr/contrib/uima/src/test-files/uima/solr/collection1/conf/schema.xml index db7c1900fb3..e2f761e3657 100644 --- a/solr/contrib/uima/src/test-files/uima/solr/collection1/conf/schema.xml +++ b/solr/contrib/uima/src/test-files/uima/solr/collection1/conf/schema.xml @@ -470,10 +470,7 @@ field type: mandatory - the name of a previously defined type from the section indexed: true if this field should be indexed (searchable or sortable) stored: true if this field should be - retrievable compressed: [false] if this field should be stored - using gzip compression (this will only apply if the field type is - compressable; among the standard field types, only TextField and - StrField are) multiValued: true if this field may contain multiple + retrievable multiValued: true if this field may contain multiple values per document omitNorms: (expert) set to true to omit the norms associated with this field (this disables length normalization and index-time boosting for the field, and saves diff --git a/solr/contrib/uima/src/test-files/uima/uima-tokenizers-schema.xml b/solr/contrib/uima/src/test-files/uima/uima-tokenizers-schema.xml index cd9a0bc3d87..37c8d98883e 100644 --- a/solr/contrib/uima/src/test-files/uima/uima-tokenizers-schema.xml +++ b/solr/contrib/uima/src/test-files/uima/uima-tokenizers-schema.xml @@ -466,10 +466,7 @@ field type: mandatory - the name of a previously defined type from the section indexed: true if this field should be indexed (searchable or sortable) stored: true if this field should be - retrievable compressed: [false] if this field should be stored - using gzip compression (this will only apply if the field type is - compressable; among the standard field types, only TextField and - StrField are) multiValued: true if this field may contain multiple + retrievable multiValued: true if this field may contain multiple values per document omitNorms: (expert) set to true to omit the norms associated with this field (this disables length normalization and index-time boosting for the field, and saves diff --git a/solr/core/src/java/org/apache/solr/schema/FieldProperties.java b/solr/core/src/java/org/apache/solr/schema/FieldProperties.java index 3a2b987b72c..2eedf05197d 100644 --- a/solr/core/src/java/org/apache/solr/schema/FieldProperties.java +++ b/solr/core/src/java/org/apache/solr/schema/FieldProperties.java @@ -64,7 +64,7 @@ public abstract class FieldProperties { static final Map propertyMap = new HashMap(); static { for (String prop : propertyNames) { - propertyMap.put(prop, propertyNameToInt(prop)); + propertyMap.put(prop, propertyNameToInt(prop, true)); } } @@ -74,13 +74,17 @@ public abstract class FieldProperties { return propertyNames[ Integer.numberOfTrailingZeros(property) ]; } - static int propertyNameToInt(String name) { + static int propertyNameToInt(String name, boolean failOnError) { for (int i=0; i properties, boolean which) { + static int parseProperties(Map properties, boolean which, boolean failOnError) { int props = 0; for (Map.Entry entry : properties.entrySet()) { String val = entry.getValue(); if(val == null) continue; if (Boolean.parseBoolean(val) == which) { - props |= propertyNameToInt(entry.getKey()); + props |= propertyNameToInt(entry.getKey(), failOnError); } } return props; diff --git a/solr/core/src/java/org/apache/solr/schema/FieldType.java b/solr/core/src/java/org/apache/solr/schema/FieldType.java index c0b8b341130..bc4095d50f5 100644 --- a/solr/core/src/java/org/apache/solr/schema/FieldType.java +++ b/solr/core/src/java/org/apache/solr/schema/FieldType.java @@ -153,8 +153,8 @@ public abstract class FieldType extends FieldProperties { this.args = Collections.unmodifiableMap(args); Map initArgs = new HashMap(args); - trueProperties = FieldProperties.parseProperties(initArgs,true); - falseProperties = FieldProperties.parseProperties(initArgs,false); + trueProperties = FieldProperties.parseProperties(initArgs,true,false); + falseProperties = FieldProperties.parseProperties(initArgs,false,false); properties &= ~falseProperties; properties |= trueProperties; diff --git a/solr/core/src/java/org/apache/solr/schema/SchemaField.java b/solr/core/src/java/org/apache/solr/schema/SchemaField.java index 8d6c42105de..1b402075e45 100644 --- a/solr/core/src/java/org/apache/solr/schema/SchemaField.java +++ b/solr/core/src/java/org/apache/solr/schema/SchemaField.java @@ -221,8 +221,8 @@ public final class SchemaField extends FieldProperties { } static int calcProps(String name, FieldType ft, Map props) { - int trueProps = parseProperties(props,true); - int falseProps = parseProperties(props,false); + int trueProps = parseProperties(props,true,true); + int falseProps = parseProperties(props,false,true); int p = ft.properties; diff --git a/solr/core/src/test-files/solr/collection1/conf/bad-schema-bogus-field-parameters.xml b/solr/core/src/test-files/solr/collection1/conf/bad-schema-bogus-field-parameters.xml new file mode 100644 index 00000000000..3575c438c72 --- /dev/null +++ b/solr/core/src/test-files/solr/collection1/conf/bad-schema-bogus-field-parameters.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + diff --git a/solr/core/src/test-files/solr/collection1/conf/schema-copyfield-test.xml b/solr/core/src/test-files/solr/collection1/conf/schema-copyfield-test.xml index 6c45681d215..68fbb219894 100644 --- a/solr/core/src/test-files/solr/collection1/conf/schema-copyfield-test.xml +++ b/solr/core/src/test-files/solr/collection1/conf/schema-copyfield-test.xml @@ -346,8 +346,8 @@ termPositions="true" termOffsets="true"/> - - + + diff --git a/solr/core/src/test-files/solr/collection1/conf/schema-required-fields.xml b/solr/core/src/test-files/solr/collection1/conf/schema-required-fields.xml index 019643f6b09..38b52c56931 100644 --- a/solr/core/src/test-files/solr/collection1/conf/schema-required-fields.xml +++ b/solr/core/src/test-files/solr/collection1/conf/schema-required-fields.xml @@ -337,8 +337,8 @@ termPositions="true" termOffsets="true"/> - - + + diff --git a/solr/core/src/test-files/solr/collection1/conf/schema-rest.xml b/solr/core/src/test-files/solr/collection1/conf/schema-rest.xml index 96e3645bcec..f372102a2d5 100755 --- a/solr/core/src/test-files/solr/collection1/conf/schema-rest.xml +++ b/solr/core/src/test-files/solr/collection1/conf/schema-rest.xml @@ -469,8 +469,8 @@ termPositions="true" termOffsets="true"/> - - + + diff --git a/solr/core/src/test-files/solr/collection1/conf/schema-trie.xml b/solr/core/src/test-files/solr/collection1/conf/schema-trie.xml index 6a8bc6e6208..85ad7b7e263 100644 --- a/solr/core/src/test-files/solr/collection1/conf/schema-trie.xml +++ b/solr/core/src/test-files/solr/collection1/conf/schema-trie.xml @@ -258,9 +258,6 @@ type: mandatory - the name of a previously defined type from the section indexed: true if this field should be indexed (searchable or sortable) stored: true if this field should be retrievable - compressed: [false] if this field should be stored using gzip compression - (this will only apply if the field type is compressable; among - the standard field types, only TextField and StrField are) multiValued: true if this field may contain multiple values per document omitNorms: (expert) set to true to omit the norms associated with this field (this disables length normalization and index-time diff --git a/solr/core/src/test-files/solr/collection1/conf/schema.xml b/solr/core/src/test-files/solr/collection1/conf/schema.xml index 884bf2abd9a..fca84bf6996 100644 --- a/solr/core/src/test-files/solr/collection1/conf/schema.xml +++ b/solr/core/src/test-files/solr/collection1/conf/schema.xml @@ -506,22 +506,22 @@ - - + + omitTermFreqAndPositions="false" omitPositions="true" /> - - + + diff --git a/solr/core/src/test-files/solr/collection1/conf/schema11.xml b/solr/core/src/test-files/solr/collection1/conf/schema11.xml index 985e8ca77dd..5c2e28171d5 100755 --- a/solr/core/src/test-files/solr/collection1/conf/schema11.xml +++ b/solr/core/src/test-files/solr/collection1/conf/schema11.xml @@ -296,9 +296,6 @@ valued. --> type: mandatory - the name of a previously defined type from the section indexed: true if this field should be indexed (searchable or sortable) stored: true if this field should be retrievable - compressed: [false] if this field should be stored using gzip compression - (this will only apply if the field type is compressable; among - the standard field types, only TextField and StrField are) multiValued: true if this field may contain multiple values per document omitNorms: (expert) set to true to omit the norms associated with this field (this disables length normalization and index-time diff --git a/solr/core/src/test-files/solr/collection1/conf/schema12.xml b/solr/core/src/test-files/solr/collection1/conf/schema12.xml index c1aa3e618ec..fb28710d77e 100755 --- a/solr/core/src/test-files/solr/collection1/conf/schema12.xml +++ b/solr/core/src/test-files/solr/collection1/conf/schema12.xml @@ -472,8 +472,8 @@ termPositions="true" termOffsets="true"/> - - + + diff --git a/solr/core/src/test-files/solr/collection1/conf/schema15.xml b/solr/core/src/test-files/solr/collection1/conf/schema15.xml index 50bb210254c..0b1cefc1cdc 100755 --- a/solr/core/src/test-files/solr/collection1/conf/schema15.xml +++ b/solr/core/src/test-files/solr/collection1/conf/schema15.xml @@ -470,8 +470,8 @@ termPositions="true" termOffsets="true"/> - - + + diff --git a/solr/core/src/test-files/solr/collection1/conf/schemasurround.xml b/solr/core/src/test-files/solr/collection1/conf/schemasurround.xml index 823e313c1eb..d6f4664076a 100644 --- a/solr/core/src/test-files/solr/collection1/conf/schemasurround.xml +++ b/solr/core/src/test-files/solr/collection1/conf/schemasurround.xml @@ -487,8 +487,8 @@ termPositions="true" termOffsets="true"/> - - + + 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 d631697e5b3..d390a4cb771 100644 --- a/solr/core/src/test/org/apache/solr/schema/BadIndexSchemaTest.java +++ b/solr/core/src/test/org/apache/solr/schema/BadIndexSchemaTest.java @@ -23,7 +23,7 @@ public class BadIndexSchemaTest extends AbstractBadConfigTestBase { private void doTest(final String schema, final String errString) throws Exception { - assertConfigs("solrconfig.xml", schema, errString); + assertConfigs("solrconfig-basic.xml", schema, errString); } public void testSevereErrorsForInvalidFieldOptions() throws Exception { @@ -110,5 +110,9 @@ public class BadIndexSchemaTest extends AbstractBadConfigTestBase { doTest("bad-schema-sweetspot-partial-norms.xml", "Overriding default lengthNorm"); } + + public void testBogusParameters() throws Exception { + doTest("bad-schema-bogus-field-parameters.xml", "Invalid field property"); + } } diff --git a/solr/example/example-DIH/solr/db/conf/schema.xml b/solr/example/example-DIH/solr/db/conf/schema.xml index 45d6662201b..50ee5e015ba 100644 --- a/solr/example/example-DIH/solr/db/conf/schema.xml +++ b/solr/example/example-DIH/solr/db/conf/schema.xml @@ -246,9 +246,6 @@ type: mandatory - the name of a previously defined type from the section indexed: true if this field should be indexed (searchable or sortable) stored: true if this field should be retrievable - compressed: [false] if this field should be stored using gzip compression - (this will only apply if the field type is compressable; among - the standard field types, only TextField and StrField are) multiValued: true if this field may contain multiple values per document omitNorms: (expert) set to true to omit the norms associated with this field (this disables length normalization and index-time diff --git a/solr/example/example-DIH/solr/mail/conf/schema.xml b/solr/example/example-DIH/solr/mail/conf/schema.xml index 663fc579111..c7cddbb93db 100644 --- a/solr/example/example-DIH/solr/mail/conf/schema.xml +++ b/solr/example/example-DIH/solr/mail/conf/schema.xml @@ -324,9 +324,6 @@ type: mandatory - the name of a previously defined type from the section indexed: true if this field should be indexed (searchable or sortable) stored: true if this field should be retrievable - compressed: [false] if this field should be stored using gzip compression - (this will only apply if the field type is compressable; among - the standard field types, only TextField and StrField are) multiValued: true if this field may contain multiple values per document omitNorms: (expert) set to true to omit the norms associated with this field (this disables length normalization and index-time diff --git a/solr/example/example-DIH/solr/rss/conf/schema.xml b/solr/example/example-DIH/solr/rss/conf/schema.xml index 38488cb8bb8..dbaa865fb12 100644 --- a/solr/example/example-DIH/solr/rss/conf/schema.xml +++ b/solr/example/example-DIH/solr/rss/conf/schema.xml @@ -273,9 +273,6 @@ type: mandatory - the name of a previously defined type from the section indexed: true if this field should be indexed (searchable or sortable) stored: true if this field should be retrievable - compressed: [false] if this field should be stored using gzip compression - (this will only apply if the field type is compressable; among - the standard field types, only TextField and StrField are) multiValued: true if this field may contain multiple values per document omitNorms: (expert) set to true to omit the norms associated with this field (this disables length normalization and index-time diff --git a/solr/example/example-DIH/solr/solr/conf/schema.xml b/solr/example/example-DIH/solr/solr/conf/schema.xml index c78d417277c..299fd379b6f 100644 --- a/solr/example/example-DIH/solr/solr/conf/schema.xml +++ b/solr/example/example-DIH/solr/solr/conf/schema.xml @@ -246,9 +246,6 @@ type: mandatory - the name of a previously defined type from the section indexed: true if this field should be indexed (searchable or sortable) stored: true if this field should be retrievable - compressed: [false] if this field should be stored using gzip compression - (this will only apply if the field type is compressable; among - the standard field types, only TextField and StrField are) multiValued: true if this field may contain multiple values per document omitNorms: (expert) set to true to omit the norms associated with this field (this disables length normalization and index-time