What is the difference between managed-schema and schema.xml

Shafs Jan picture Shafs Jan · Oct 5, 2016 · Viewed 9.3k times · Source

I have below questions in solr 6.

  1. What is the main difference between managed-schema and schema.xml
  2. What are the benefits and disadvantages while using managed-schema and schema.xml(classic).

And could you please help me in understanding what is recommended in solr6?

Regards,

Shaffic

Answer

Brandon Deo picture Brandon Deo · Jan 24, 2017

I've done some investigation after wondering the same thing and here's the best I can come up with.

It seems that schema.xml and managed-schema are indentical, only their name changed in Solr6.

Benefits of managed-schema

  • The benefits are that you can more safely make changes to your schema without fear of making typos or creating an invalid schema. The API would reject your changes if something is invalid.
  • The Schema API also handles all of the reloading of your cores after the schema has changed so you don't have to.

Drawbacks of managed-schema

  • You shouldn't make manual edits to the managed-schema and therefore you should go through the API, this makes it harder to keep track of the current state of your schema (e.g. via Version Control)

    Note: The Schema API has an endpoint to get the managed-schema with a special param curl http://localhost:8983/solr/<COLLECTION>/schema?wt=schema.xml

Note: If you have a schema.xml file and do not have a managed-schema at the time of starting Solr and do not have schemaFactory specified in your solrconfig.xml file, Solr will assume it is managed, and create a managed_schema from your schema.xml file, at which point your schema.xml file is no longer read from. The managed-schema will be read from at this point forward. Further changes to schema.xml will be ignored.