Question

I have a number of sites which I am indexing using Solr 4.6.0 and I wish to maintain separate cores for each. Each of the cores will share the same schema.xml and same solrconfig.xml. Ideally, I would be able to create new cores through the admin console and Solr would pick up my default core configuration.

Currently, when I create a new core I am creating a new directory in the filesystem named as I would want the core to be. I am then adding to that:

  1. A core.properties file (which just contains a single name=myycorename property.
  2. A conf folder with a copy of the generic schema.xml and solrconfig.xml files

I have tried putting the following in the core.properties file a level up and referencing relatively:

schema=../configs/template/schema.xml
config=../configs/solrconfig.xml

I have also tried symlinking (not ideal as I would like this to run on windows/osx/linux.

But Solr does not seem to like relative references outside of the directory. The configName property mentioned in Core Discovery 4.4 and Beyond

Is it possible to have this kind of default configuration within Solr?

Was it helpful?

Solution

As of Solr 4.8, cores can use config sets to share common configurations (i.e., "solrconfig.xml", "schema.xml", etc.) between multiple cores.

You want to change your directory structure to:

./
├─ solr.xml
├─ configsets/
|  └─ template/
|     └─ conf/
|        ├─ schema.xml
|        ├─ solrconfig.xml
|        └─ ...
├─ core1/
|  ├─ core.properties
|  └─ data/
└─ core2/
   ├─ core.properties
   └─ data/

This defines one config set named template. Everything that would go under the core's "conf/" directory should be under the config set's "conf/" directory.

Then, in each of your "core.properties" files, set configSet and omit schema and config:

# core.properties
name=...
configSet=template

Now your cores using the template config set will share "schema.xml", "solrconfig.xml", etc.

Unfortunately, the admin interface doesn't directly support assigning the configSet property. But if you use the CoreAdmin API, you can set configSet with the CREATE command. E.g.,

http://localhost:8983/solr/admin/cores?action=CREATE&name=coreX&configSet=template

OTHER TIPS

When you create a new core, it shares the config files of the existing Solr instance by default. But you can mention different config files for the newly created cores. Please refer http://wiki.apache.org/solr/CoreAdmin

config=different_solrconfig.xml&schema=different_schema.xml
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top