Skip to content

Apache Lucene open-source search software

SOLR-5228: Deprecate <fields> and <types> tags in schema.xml

Erick Erickson9a8a4c7c7fbf
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 6a49d3d9792..dc6f571756f 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -142,6 +142,9 @@ New Features
* SOLR-5860: Use leaderConflictResolveWait in WaitForState during recovery/startup,
improve logging and force refresh cluster state every 15 seconds.
(Timothy Potter via shalin)
+
+ * SOLR-5228: Don't require <field> or <dynamicField> be inside of <fields> -- or
+ that <fieldType> be inside of <types>. (Erick Erickson)
* SOLR-5749: A new Overseer status collection API exposes overseer queue sizes, timing
statistics, success and error counts and last N failures per operation. (shalin)
diff --git a/solr/core/src/java/org/apache/solr/response/SchemaXmlWriter.java b/solr/core/src/java/org/apache/solr/response/SchemaXmlWriter.java
index a6fe98ddc2e..950eae27f2a 100644
--- a/solr/core/src/java/org/apache/solr/response/SchemaXmlWriter.java
+++ b/solr/core/src/java/org/apache/solr/response/SchemaXmlWriter.java
@@ -111,9 +111,6 @@ public class SchemaXmlWriter extends TextResponseWriter {
} else if (schemaPropName.equals(IndexSchema.FIELD_TYPES)) {
writeFieldTypes((List<SimpleOrderedMap<Object>>)schemaProperties.getVal(schemaPropNum));
} else if (schemaPropName.equals(IndexSchema.FIELDS)) {
- openStartTag(IndexSchema.FIELDS);
- closeStartTag(false);
- incLevel();
@SuppressWarnings("unchecked") List<SimpleOrderedMap<Object>> fieldPropertiesList
= (List<SimpleOrderedMap<Object>>)schemaProperties.getVal(schemaPropNum);
for (SimpleOrderedMap<Object> fieldProperties : fieldPropertiesList) {
@@ -134,8 +131,6 @@ public class SchemaXmlWriter extends TextResponseWriter {
}
closeStartTag(true);
}
- decLevel();
- endTag(IndexSchema.FIELDS);
} else if (schemaPropName.equals(IndexSchema.COPY_FIELDS)) {
@SuppressWarnings("unchecked") List<SimpleOrderedMap<Object>> copyFieldPropertiesList
= (List<SimpleOrderedMap<Object>>)schemaProperties.getVal(schemaPropNum);
@@ -156,9 +151,6 @@ public class SchemaXmlWriter extends TextResponseWriter {
}
private void writeFieldTypes(List<SimpleOrderedMap<Object>> fieldTypePropertiesList) throws IOException {
- openStartTag(IndexSchema.TYPES);
- closeStartTag(false);
- incLevel();
for (SimpleOrderedMap<Object> fieldTypeProperties : fieldTypePropertiesList) {
SimpleOrderedMap<Object> analyzerProperties = null;
SimpleOrderedMap<Object> indexAnalyzerProperties = null;
@@ -199,8 +191,6 @@ public class SchemaXmlWriter extends TextResponseWriter {
endTag(IndexSchema.FIELD_TYPE);
}
}
- decLevel();
- endTag(IndexSchema.TYPES);
}
private void writeSimilarity(SimpleOrderedMap<Object> similarityProperties) throws IOException {
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 0263d7aad9f..fe47f4f8651 100644
--- a/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
+++ b/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
@@ -463,8 +463,10 @@ public class IndexSchema {
final FieldTypePluginLoader typeLoader = new FieldTypePluginLoader(this, fieldTypes, schemaAware);
- // /schema/types/fieldtype | /schema/types/fieldType
- expression = stepsToPath(SCHEMA, TYPES, FIELD_TYPE.toLowerCase(Locale.ROOT)) // backcompat(?)
+ // /schema/fieldtype | /schema/fieldType | /schema/types/fieldtype | /schema/types/fieldType
+ expression = stepsToPath(SCHEMA, FIELD_TYPE.toLowerCase(Locale.ROOT)) // backcompat(?)
+ + XPATH_OR + stepsToPath(SCHEMA, FIELD_TYPE)
+ + XPATH_OR + stepsToPath(SCHEMA, TYPES, FIELD_TYPE.toLowerCase(Locale.ROOT))
+ XPATH_OR + stepsToPath(SCHEMA, TYPES, FIELD_TYPE);
NodeList nodes = (NodeList) xpath.evaluate(expression, document, XPathConstants.NODESET);
typeLoader.load(loader, nodes);
@@ -637,9 +639,12 @@ public class IndexSchema {
ArrayList<DynamicField> dFields = new ArrayList<>();
- // /schema/fields/field | /schema/fields/dynamicField
- String expression = stepsToPath(SCHEMA, FIELDS, FIELD)
- + XPATH_OR + stepsToPath(SCHEMA, FIELDS, DYNAMIC_FIELD);
+ // /schema/field | /schema/dynamicField | /schema/fields/field | /schema/fields/dynamicField
+ String expression = stepsToPath(SCHEMA, FIELD)
+ + XPATH_OR + stepsToPath(SCHEMA, DYNAMIC_FIELD)
+ + XPATH_OR + stepsToPath(SCHEMA, FIELDS, FIELD)
+ + XPATH_OR + stepsToPath(SCHEMA, FIELDS, DYNAMIC_FIELD);
+
NodeList nodes = (NodeList)xpath.evaluate(expression, document, XPathConstants.NODESET);
for (int i=0; i<nodes.getLength(); i++) {
diff --git a/solr/core/src/test-files/solr/collection1/conf/schema-add-schema-fields-update-processor.xml b/solr/core/src/test-files/solr/collection1/conf/schema-add-schema-fields-update-processor.xml
index 2b59472f5f0..35507793a53 100644
--- a/solr/core/src/test-files/solr/collection1/conf/schema-add-schema-fields-update-processor.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/schema-add-schema-fields-update-processor.xml
@@ -17,22 +17,22 @@
-->
<schema name="add-schema-fields-update-processor" version="1.5">
- <types>
- <fieldType name="tint" class="solr.TrieIntField" precisionStep="8" multiValued="true" positionIncrementGap="0"/>
- <fieldType name="tfloat" class="solr.TrieFloatField" precisionStep="8" multiValued="true" positionIncrementGap="0"/>
- <fieldType name="tlong" class="solr.TrieLongField" precisionStep="8" multiValued="true" positionIncrementGap="0"/>
- <fieldType name="tdouble" class="solr.TrieDoubleField" precisionStep="8" multiValued="true" positionIncrementGap="0"/>
- <fieldType name="tdate" class="solr.TrieDateField" precisionStep="6" multiValued="true" positionIncrementGap="0"/>
- <fieldtype name="boolean" class="solr.BoolField" sortMissingLast="true" multiValued="true"/>
- <fieldtype name="string" class="solr.StrField" sortMissingLast="true"/>
- <fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/>
- <fieldType name="text" class="solr.TextField" multiValued="true" positionIncrementGap="100">
- <analyzer>
- <tokenizer class="solr.StandardTokenizerFactory"/>
- <filter class="solr.LowerCaseFilterFactory"/>
- </analyzer>
- </fieldType>
- </types>
+
+ <fieldType name="tint" class="solr.TrieIntField" precisionStep="8" multiValued="true" positionIncrementGap="0"/>
+ <fieldType name="tfloat" class="solr.TrieFloatField" precisionStep="8" multiValued="true" positionIncrementGap="0"/>
+ <fieldType name="tlong" class="solr.TrieLongField" precisionStep="8" multiValued="true" positionIncrementGap="0"/>
+ <fieldType name="tdouble" class="solr.TrieDoubleField" precisionStep="8" multiValued="true" positionIncrementGap="0"/>
+ <fieldType name="tdate" class="solr.TrieDateField" precisionStep="6" multiValued="true" positionIncrementGap="0"/>
+ <fieldtype name="boolean" class="solr.BoolField" sortMissingLast="true" multiValued="true"/>
+ <fieldtype name="string" class="solr.StrField" sortMissingLast="true"/>
+ <fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/>
+ <fieldType name="text" class="solr.TextField" multiValued="true" positionIncrementGap="100">
+ <analyzer>
+ <tokenizer class="solr.StandardTokenizerFactory"/>
+ <filter class="solr.LowerCaseFilterFactory"/>
+ </analyzer>
+ </fieldType>
+
<fields>
<field name="id" type="string" indexed="true" stored="true" multiValued="false" required="true"/>
<field name="_version_" type="long" indexed="true" stored="true"/>
diff --git a/solr/core/src/test-files/solr/collection1/conf/schema-tiny.xml b/solr/core/src/test-files/solr/collection1/conf/schema-tiny.xml
index 08e0aebc42f..6a62d3758bb 100644
--- a/solr/core/src/test-files/solr/collection1/conf/schema-tiny.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/schema-tiny.xml
@@ -16,15 +16,14 @@
limitations under the License.
-->
<schema name="tiny" version="1.1">
- <types>
- <fieldType name="string" class="solr.StrField"/>
- </types>
- <fields>
- <field name="id" type="string" indexed="true" stored="true" required="true"/>
- <field name="text" type="text" indexed="true" stored="true"/>
- <dynamicField name="*_t" type="text" indexed="true" stored="true"/>
- <dynamicField name="*" type="string" indexed="true" stored="true"/>
- </fields>
+ <fieldType name="string" class="solr.StrField"/>
+
+
+ <field name="id" type="string" indexed="true" stored="true" required="true"/>
+ <field name="text" type="text" indexed="true" stored="true"/>
+ <dynamicField name="*_t" type="text" indexed="true" stored="true"/>
+ <dynamicField name="*" type="string" indexed="true" stored="true"/>
+
<uniqueKey>id</uniqueKey>
<types>
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 ea4edd553aa..69723c6d451 100755
--- a/solr/core/src/test-files/solr/collection1/conf/schema11.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/schema11.xml
@@ -37,7 +37,7 @@
1.0: multiValued attribute did not exist, all fields are multiValued by nature
1.1: multiValued attribute introduced, false by default -->
- <types>
+
<!-- field type definitions. The "name" attribute is
just a label to be used by field definitions. The "class"
attribute and any other attributes determine the real
@@ -297,10 +297,7 @@ valued. -->
</analyzer>
</fieldtype>
- </types>
-
- <fields>
<!-- Valid attributes for fields:
name: mandatory - the name for the field
type: mandatory - the name of a previously defined type from the <types> section
@@ -387,7 +384,6 @@ valued. -->
unknown fields indexed and/or stored by default -->
<!--dynamicField name="*" type="ignored" /-->
- </fields>
<!-- Field to use to determine and enforce document uniqueness.
Unless this field is marked with required="false", it will be a required field
diff --git a/solr/core/src/test/org/apache/solr/rest/schema/TestSchemaResource.java b/solr/core/src/test/org/apache/solr/rest/schema/TestSchemaResource.java
index 32a3de532a5..aed5d7c4782 100644
--- a/solr/core/src/test/org/apache/solr/rest/schema/TestSchemaResource.java
+++ b/solr/core/src/test/org/apache/solr/rest/schema/TestSchemaResource.java
@@ -160,17 +160,17 @@ public class TestSchemaResource extends SolrRestletTestBase {
"/schema/uniqueKey = 'id'",
"/schema/defaultSearchField = 'text'",
- "(/schema/types/fieldType)[1]/@name = 'HTMLstandardtok'",
- "(/schema/types/fieldType)[2]/@name = 'HTMLwhitetok'",
- "(/schema/types/fieldType)[3]/@name = 'boolean'",
+ "(/schema/fieldType)[1]/@name = 'HTMLstandardtok'",
+ "(/schema/fieldType)[2]/@name = 'HTMLwhitetok'",
+ "(/schema/fieldType)[3]/@name = 'boolean'",
- "(/schema/fields/field)[1]/@name = 'HTMLstandardtok'",
- "(/schema/fields/field)[2]/@name = 'HTMLwhitetok'",
- "(/schema/fields/field)[3]/@name = '_version_'",
+ "(/schema/field)[1]/@name = 'HTMLstandardtok'",
+ "(/schema/field)[2]/@name = 'HTMLwhitetok'",
+ "(/schema/field)[3]/@name = '_version_'",
- "(/schema/fields/dynamicField)[1]/@name = '*_coordinate'",
- "(/schema/fields/dynamicField)[2]/@name = 'ignored_*'",
- "(/schema/fields/dynamicField)[3]/@name = '*_mfacet'",
+ "(/schema/dynamicField)[1]/@name = '*_coordinate'",
+ "(/schema/dynamicField)[2]/@name = 'ignored_*'",
+ "(/schema/dynamicField)[3]/@name = '*_mfacet'",
"/schema/copyField[@source='title'][@dest='title_stemmed'][@maxChars='200']",
"/schema/copyField[@source='title'][@dest='dest_sub_no_ast_s']",
diff --git a/solr/example/example-DIH/solr/db/conf/schema.xml b/solr/example/example-DIH/solr/db/conf/schema.xml
index 50ee5e015ba..1ce7fd9b91c 100644
--- a/solr/example/example-DIH/solr/db/conf/schema.xml
+++ b/solr/example/example-DIH/solr/db/conf/schema.xml
@@ -37,7 +37,7 @@
1.0: multiValued attribute did not exist, all fields are multiValued by nature
1.1: multiValued attribute introduced, false by default -->
- <types>
+
<!-- field type definitions. The "name" attribute is
just a label to be used by field definitions. The "class"
attribute and any other attributes determine the real
@@ -237,10 +237,10 @@
-->
<fieldtype name="ignored" stored="false" indexed="false" class="solr.StrField" />
- </types>
- <fields>
+
+
<!-- Valid attributes for fields:
name: mandatory - the name for the field
type: mandatory - the name of a previously defined type from the <types> section
@@ -314,7 +314,6 @@
unknown fields indexed and/or stored by default -->
<!--dynamicField name="*" type="ignored" multiValued="true" /-->
- </fields>
<!-- Field to use to determine and enforce document uniqueness.
Unless this field is marked with required="false", it will be a required field
diff --git a/solr/example/example-DIH/solr/mail/conf/schema.xml b/solr/example/example-DIH/solr/mail/conf/schema.xml
index 5c48a0257a0..af79d4dec63 100644
--- a/solr/example/example-DIH/solr/mail/conf/schema.xml
+++ b/solr/example/example-DIH/solr/mail/conf/schema.xml
@@ -41,7 +41,7 @@
1.1: multiValued attribute introduced, false by default
1.2: omitTf attribute introduced, true by default -->
- <types>
+
<!-- field type definitions. The "name" attribute is
just a label to be used by field definitions. The "class"
attribute and any other attributes determine the real
@@ -311,10 +311,6 @@
-->
<fieldtype name="ignored" stored="false" indexed="false" class="solr.StrField" />
- </types>
-
-
- <fields>
<!-- Valid attributes for fields:
name: mandatory - the name for the field
type: mandatory - the name of a previously defined type from the <types> section
@@ -346,8 +342,6 @@
<field name="catchAllField" type="text" indexed="true" stored="true" omitNorms="true" multiValued="true"/>
- </fields>
-
<copyField source="content" dest="catchAllField"/>
<copyField source="attachmentNames" dest="catchAllField"/>
<copyField source="attachment" dest="catchAllField"/>
diff --git a/solr/example/example-DIH/solr/solr/conf/schema.xml b/solr/example/example-DIH/solr/solr/conf/schema.xml
index 299fd379b6f..0e83032edff 100644
--- a/solr/example/example-DIH/solr/solr/conf/schema.xml
+++ b/solr/example/example-DIH/solr/solr/conf/schema.xml
@@ -37,7 +37,7 @@
1.0: multiValued attribute did not exist, all fields are multiValued by nature
1.1: multiValued attribute introduced, false by default -->
- <types>
+
<!-- field type definitions. The "name" attribute is
just a label to be used by field definitions. The "class"
attribute and any other attributes determine the real
@@ -237,10 +237,6 @@
-->
<fieldtype name="ignored" stored="false" indexed="false" class="solr.StrField" />
- </types>
-
-
- <fields>
<!-- Valid attributes for fields:
name: mandatory - the name for the field
type: mandatory - the name of a previously defined type from the <types> section
@@ -314,8 +310,6 @@
unknown fields indexed and/or stored by default -->
<!--dynamicField name="*" type="ignored" multiValued="true" /-->
- </fields>
-
<!-- Field to use to determine and enforce document uniqueness.
Unless this field is marked with required="false", it will be a required field
-->
diff --git a/solr/example/example-DIH/solr/tika/conf/schema.xml b/solr/example/example-DIH/solr/tika/conf/schema.xml
index b1ec8be51ed..63d75ac9733 100644
--- a/solr/example/example-DIH/solr/tika/conf/schema.xml
+++ b/solr/example/example-DIH/solr/tika/conf/schema.xml
@@ -37,7 +37,6 @@
1.0: multiValued attribute did not exist, all fields are multiValued by nature
1.1: multiValued attribute introduced, false by default -->
- <types>
<!-- field type definitions. The "name" attribute is
just a label to be used by field definitions. The "class"
attribute and any other attributes determine the real
@@ -187,15 +186,10 @@
-->
<fieldtype name="ignored" stored="false" indexed="false" class="solr.StrField" />
- </types>
-
-
- <fields>
<field name="title" type="string" indexed="true" stored="true"/>
<field name="author" type="string" indexed="true" stored="true" />
<field name="text" type="text" indexed="true" stored="true" />
- </fields>
<!-- field for the QueryParser to use when an explicit fieldname is absent -->
<defaultSearchField>text</defaultSearchField>
diff --git a/solr/example/example-schemaless/solr/collection1/conf/schema.xml b/solr/example/example-schemaless/solr/collection1/conf/schema.xml
index a15771596a3..ecf5492349e 100755
--- a/solr/example/example-schemaless/solr/collection1/conf/schema.xml
+++ b/solr/example/example-schemaless/solr/collection1/conf/schema.xml
@@ -63,7 +63,6 @@
(int, float, boolean, string...)
-->
- <fields>
<!-- Valid attributes for fields:
name: mandatory - the name for the field
type: mandatory - the name of a field type from the
@@ -168,7 +167,6 @@
unknown fields to the schema. -->
<!--dynamicField name="*" type="ignored" multiValued="true" /-->
- </fields>
<!-- Field to use to determine and enforce document uniqueness.
@@ -232,7 +230,7 @@
<!-- copy name to alphaNameSort, a field designed for sorting by name -->
<!-- <copyField source="name" dest="alphaNameSort"/> -->
- <types>
+
<!-- field type definitions. The "name" attribute is
just a label to be used by field definitions. The "class"
attribute and any other attributes determine the real
@@ -1056,7 +1054,6 @@
</analyzer>
</fieldType>
- </types>
<!-- Similarity is the scoring routine for each document vs. a query.
A custom Similarity or SimilarityFactory may be specified here, but
diff --git a/solr/example/multicore/core0/conf/schema.xml b/solr/example/multicore/core0/conf/schema.xml
index 7401b5b58ed..1f2d33ed3df 100644
--- a/solr/example/multicore/core0/conf/schema.xml
+++ b/solr/example/multicore/core0/conf/schema.xml
@@ -17,19 +17,15 @@
-->
<schema name="example core zero" version="1.1">
- <types>
+
<fieldtype name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
<fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/>
- </types>
-
- <fields>
<!-- general -->
<field name="id" type="string" indexed="true" stored="true" multiValued="false" required="true"/>
<field name="type" type="string" indexed="true" stored="true" multiValued="false" />
<field name="name" type="string" indexed="true" stored="true" multiValued="false" />
<field name="core0" type="string" indexed="true" stored="true" multiValued="false" />
<field name="_version_" type="long" indexed="true" stored="true"/>
- </fields>
<!-- field to use to determine and enforce document uniqueness. -->
<uniqueKey>id</uniqueKey>
diff --git a/solr/example/multicore/core1/conf/schema.xml b/solr/example/multicore/core1/conf/schema.xml
index 5a27d39df2d..c9584537a39 100644
--- a/solr/example/multicore/core1/conf/schema.xml
+++ b/solr/example/multicore/core1/conf/schema.xml
@@ -17,19 +17,16 @@
-->
<schema name="example core one" version="1.1">
- <types>
+
<fieldtype name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
<fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/>
- </types>
- <fields>
<!-- general -->
<field name="id" type="string" indexed="true" stored="true" multiValued="false" required="true"/>
<field name="type" type="string" indexed="true" stored="true" multiValued="false" />
<field name="name" type="string" indexed="true" stored="true" multiValued="false" />
<field name="core1" type="string" indexed="true" stored="true" multiValued="false" />
<field name="_version_" type="long" indexed="true" stored="true"/>
- </fields>
<!-- field to use to determine and enforce document uniqueness. -->
<uniqueKey>id</uniqueKey>
diff --git a/solr/example/solr/collection1/conf/schema.xml b/solr/example/solr/collection1/conf/schema.xml
index 55dbed10f11..adaedfdbf8a 100755
--- a/solr/example/solr/collection1/conf/schema.xml
+++ b/solr/example/solr/collection1/conf/schema.xml
@@ -63,7 +63,7 @@
(int, float, boolean, string...)
-->
-<fields>
+
<!-- Valid attributes for fields:
name: mandatory - the name for the field
type: mandatory - the name of a field type from the
@@ -242,7 +242,7 @@
unknown fields indexed and/or stored by default -->
<!--dynamicField name="*" type="ignored" multiValued="true" /-->
- </fields>
+
<!-- Field to use to determine and enforce document uniqueness.
@@ -302,7 +302,7 @@
<!-- copy name to alphaNameSort, a field designed for sorting by name -->
<!-- <copyField source="name" dest="alphaNameSort"/> -->
- <types>
+
<!-- field type definitions. The "name" attribute is
just a label to be used by field definitions. The "class"
attribute and any other attributes determine the real
@@ -1138,8 +1138,6 @@
<filter class="solr.SnowballPorterFilterFactory" language="Turkish"/>
</analyzer>
</fieldType>
-
- </types>
<!-- Similarity is the scoring routine for each document vs. a query.
A custom Similarity or SimilarityFactory may be specified here, but