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:
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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With