Solr 5 uses a managed schema by default, while Solr 4 used the schema.xml file. Solr 5 automatically creates the schema for you by guessing the type of the field. Once the type is assigned to the field, you can't change it. You have to set the type of the field before you add data to Solr 5.
To change the schema in Solr 5, you will want to use the Schema API, which is a REST interface. Go to https://cwiki.apache.org/confluence/display/solr/Schema+API
https://cwiki.apache.org/confluence/display/solr/Schemaless+Mode describes a little bit about the Schemaless Mode (i.e. managed schema). That page states the following:
"You Can Still Be Explicit - Even if you want to use schemaless mode for most fields, you can still use the Schema API to pre-emptively create some fields, with explicit types, before you index documents that use them. ... Once a field has been added to the schema, its field type is fixed."
If you are using the quick start guide for Solr 5, here's what you have to do if you want to explicitly specify the field types:
After you enter the following command:
bin/solr start -e cloud -noprompt
Then enter a command like this:
curl -X POST -H 'Content-type:application/json' --data-binary '{ "add-field" : { "name":"MYFIELDNAMEHERE", "type":"tlong", "stored":true}}' http://localhost:8983/solr/gettingstarted/schema
The previous command will force the MYFIELDNAMEHERE field to be a tlong. Replace MYFIELDNAMEHERE with the field name that you want to be explicitly set, and change tlong to the Solr type that you want to use.
After doing that, then load your data as usual.
No comments:
Post a Comment