Jayce444
Jayce444

Reputation: 9073

Programatically change non-managed Solr schema

I've been looking to make a tool to help speed up and streamline editing of our Solr schemas. After looking into, it seems that only managed schema can be edited by the Schema API. Unfortunately most of our collections use a schema.xml with the ClassicIndexSchemaFactory.

What we've been doing for those is keeping the conf files in our repo, then when we want to make a change, we edit those files manually in an IDE, then run a shell script which upconfs them using zkcli.sh. After looking around I can't see any way other than this manual editing to change the schema.

If we wanted to, say, programatically add a field to our schema.xml, would the only way be to have a script that literally edits the XML file content?

Upvotes: 0

Views: 59

Answers (1)

MatsLindh
MatsLindh

Reputation: 52920

Yes, unless you want to use the managed schema, that is your option.

The managed schema feature however, is exactly the feature you're asking about. It allows you to programatically make changes to the schema through the API, and you can then extract the current configuration and add it to your version controlled repo as the current schema.xml. It also allows you to write migration scripts to add fields to the currently running instance.

Also be aware that you can make manual changes to the managed schema (by editing the managed schema xml file), but it's not recommended as it requires you to be be careful if you decide to do that (make sure no node is changing the schema while you do it, make sure each node picks up the change, etc.).

Upvotes: 1

Related Questions