solrlucenesolr-search

Update managed-schema file in solr in multiple cores at once


I am working on Solr. I have multiple cores with same fields and types(same schema).Every core has its own schema(managed-schema) file in Solr .I want to add new field to the schema for all cores.

I am doing it via admin panel for each core manually.Is there any way that I can add new fields to schema of all cores at once.


Solution

  • Configure your cores to use a configset instead.

    On a multicore Solr instance, you may find that you want to share configuration between a number of different cores. You can achieve this using named configsets, which are essentially shared configuration directories stored under a configurable configset base directory.

    From the reference manual:

    If you are using Solr in standalone mode, configsets are created on the filesystem.

    To create a configset, add a new directory under the configset base directory. The configset will be identified by the name of this directory. Then into this copy the configuration directory you want to share. The structure should look something like this:

    /configset1
        /conf
            /managed-schema
            /solrconfig.xml
    /configset2
        /conf
            /managed-schema
            /solrconfig.xml
    

    The default base directory is $SOLR_HOME/configsets

    To create a new core using a configset, pass configSet as one of the core properties. For example, if you do this via the CoreAdmin API:

    curl http://localhost:8983/admin/cores?action=CREATE&name=mycore&instanceDir=path/to/instance&configSet=configset2

    As far as I know there is no way to make an existing core use a config set, so you'll have to back up your configuration and cores, then remove the cores from Solr (do not delete the directories), then readd the cores with the configSet parameter set to the name of your configset.