Many users have asked how to update the Solr schema file in their deployments. Solr documentation recommends using the Solr Schema API to update the schema, but many Solr users find it burdensome and unintuitive. They prefer to edit the schema file locally in a text editor and then upload it. The two approaches both work, as long as you don’t mix them.
The following procedure uses the edit-locally-and-upload strategy. The critical part is that changes to field definitions invalidate the collection’s index. The index must be wiped and the documents reloaded as part of a schema update. The process occurs in four steps.
Zookeeper Best Practice
The examples below rely on zkcli, the Zookeeper upload/download utility. This is appropriate to your initial experiments, but it is not the best way to interact with Zookeeper.
For truly secure Zookeeper management, use the SearchStax API. The API’s Zookeeper methods require SearchStax user authentication, and they record entries in the SearchStax access logs. Even better, they are not affected by changes in IP addresses.
Download a copy of the schema!
If you don’t have a copy of your Solr configuration, you can download one.
1. Update Schema (upload a new configuration to Zookeeper).
Edit your schema.xml or managed-schema file in a text editor. Be sure to save it in your local copy of your project-configuration directory.
When you are ready to deploy your new schema file, simply use zkcli to upload your configuration directory to your Zookeeper ensemble. (See zkcli download instructions.)
Run zkcli in a terminal window:
./zkcli.sh -zkhost <zookeeper URLs> -cmd upconfig -confdir <conf directory> -confname <config name>
where <zookeeper URLs> corresponds to the URLs of the Zookeeper servers in the deployment details page:
<conf directory> is you local Solr configuration directory (
../configsets/_default/conf/); and <config name> is the name of the configuration in Zookeeper (
2. Delete Data (delete existing index)
To delete the existing data from your collection, open a terminal window and run the following cURL command:
where <load_balancer_URL> is the Solr HTTP Endpoint URL from the deployment details page;
and <collection_name> is the name of the Solr collection (
The phrase <delete><query>*:*</query></delete> is literal. This query matches all of the records in the collection’s index and deletes them.
Are you using Solr Basic Auth?
If your deployment uses Solr Basic Auth, you will need to add your Solr username and password to the cURL command, as in:
curl -u 'username:password' 'https:/<load_balancer_url>/solr/<collection_name>/update?stream.body=<delete><query>*:*</query></delete>&commit=true'
3. Reload Collection (distribute new configuration from Zookeeper)
The next step is to download the new configuration from the Zookeeper ensemble to the Solr servers.
where <load_balancer_URL> is the Solr HTTP Endpoint URL from the SearchStax dashboard, and <collection_name> is the name of the Solr collection (
4. Reload Data (re-ingest documents)
We presume that you already know how to ingest documents, but here’s a reminder:
Run the following cURL command from a terminal window.
curl -X POST -H 'Content-type:application/json' -d <datafile_path> 'https://<load_balancer_URL>/solr/<collection_name>/update?commit=true'
where <load_balancer_URL> is the Solr HTTP Endpoint URL from the deployment details page, <datafile_path> is the location of the document file (
@sample.json), and <collection_name> is the name of the Solr collection (