Schemaless Mode is a set of Solr features that, when used together, allow users to rapidly construct an effective schema by simply indexing sample data, without having to manually edit the schema. These Solr features, all specified in
- Managed schema: Schema modifications are made through Solr APIs rather than manual edits - see Managed Schema Definition in SolrConfig.
- Field value class guessing: Previously unseen fields are run through a cascading set of value-based parsers, which guess the Java class of field values - parsers for Boolean, Integer, Long, Float, Double, and Date are currently available.
- Automatic schema field addition, based on field value class(es): Previously unseen fields are added to the schema, based on field value Java classes, which are mapped to schema field types - see Solr Field Types.
These three features are pre-configured in the
example/example-schemaless/solr/ directory in the Solr distribution. To start Solr in this pre-configured schemaless mode, go to the
example/ directory and start up Solr, setting the
solr.solr.home system property to this directory on the command line:
The schema in
example-schemaless/solr/collection1/conf/ is shipped with only two fields,
_version_, as can be seen from calling the
/schema/fields Schema API -
curl http://localhost:8983/solr/schema/fields outputs:
Adding a CSV document will cause its fields that are not in the schema to be added, with fieldTypes based on values:
Output indicating success:
The fields now in the schema (output from
curl http://localhost:8983/solr/schema/fields ):
Once a field has been added to the schema, its field type is fixed. As a consequence, adding documents with field value(s) that conflict with the previously guessed field type will fail. For example, after adding the above document, the
Sold field has fieldType
tlongs, but the document below has a non-integral decimal value in this field:
Output indicating failure: