Move from schema.xml to managed-schema

Configuration

Managed schema mode lets Solr rewrite its own schema through the Schema API, which is what integrations like the Drupal Search API expect. Switching is one element in solrconfig.xml plus a reload.

01 · Why switch

The Schema API becomes available

Fields and field types can be added, changed and removed over HTTP, without editing XML by hand.

Some integrations require it

The Drupal Search API Solr module, among others, configures its fields through that API. On a classic schema it cannot.

Schema changes fit into a pipeline

A deployment script or CI job can apply schema changes with plain HTTP requests.

02 · The change

In solrconfig.xml, find the schemaFactory definition and replace it with:

<schemaFactory class="ManagedIndexSchemaFactory">
  <bool name="mutable">true</bool>
  <str name="managedSchemaResourceName">managed-schema</str>
</schemaFactory>

If there is no schemaFactory at all, add the block anywhere before the first <requestHandler>. Setting mutable to true is what allows the Schema API to write; with false the managed schema is read-only and every modification request is rejected.

03 · Step by step

Open the config files editor

In your Opensolr index control panel.

Replace the factory

If you see ClassicIndexSchemaFactory, replace it with the block above. Remove the old definition entirely.

Save the file

Straight from the editor.

Reload the index

Solr then reads your existing schema.xml and writes a managed-schema from it. The original file stays on disk but is no longer used.

04 · What usually goes wrong

MistakeWhat you see
Both factories left in the fileThe core refuses to start. There can be only one schemaFactory.
Editing managed-schema by handYour edits are overwritten by Solr on reload. In managed mode, use the Schema API.
Saving without reloadingNothing happens at all. The migration runs on reload.
An existing syntax error in schema.xmlThe migration fails on reload. Fix the XML first, then switch the factory.

05 · Verify it worked

Check the error log

A clean reload, with no errors in the Error Log of your control panel, means the migration succeeded.

Call the Schema API

A JSON response listing your fields means managed mode is live:

curl "https://YOUR_HOSTNAME/solr/YOUR_CORE/schema/fields"

Compare against the old schema

Check that the fields and field types in the response match what your schema.xml defined. Anything missing is worth fixing before you index.

Going back to classic mode is the same operation in reverse. The steps are in my schema.xml does not take effect, which explains how to restore ClassicIndexSchemaFactory.