Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shared schema and configuration across multiple Solr 4.6 cores

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?

like image 350
diffa Avatar asked Jan 16 '14 22:01

diffa


1 Answers

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
like image 103
Uyghur Lives Matter Avatar answered Nov 15 '22 12:11

Uyghur Lives Matter