Shared schema and configuration across multiple Solr 4.6 cores
Asked Answered
L

2

5

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?

Llovera answered 16/1, 2014 at 22:9 Comment(0)
V
7

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
Vinson answered 1/5, 2015 at 17:32 Comment(3)
I've been trying these with a solrcloud config but it does not seem to pick up the "configSet". My cores in zk are under a "configs" folder and I put the "template" under /configsets but no luck. I get the error "Error CREATEing SolrCore 'test1': Unable to create core [test1] Caused by: Could not find configName for collection test1 found:[docs, users, .system]". Maybe I need to put the "configsets" folder somewhere else?Coen
@Coen I'm not really sure without knowing more about your setup. You should create a new question asking about this.Vinson
I did and answered myself at #36715693Coen
B
0

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
Bebe answered 29/1, 2014 at 7:37 Comment(2)
I guess by "existing Solr instance" you mean the default core (e.g. collection1). I think this creates a copy of the configuration files, rather than sharing a configuration. If I have 10 cores on the same configuration, they may be created from the same template. But I would need to make 10 updates if the config changesLlovera
There are 2 different things. One is Solr instance and another is Solr core. In a single solr instance you can create multiple cores. By default all the cores will share the default configuration of default core (e.g. collection1). I had a Solr instance running with single core. Later, when I created the other cores, I didn't find any copy of the configs. But the new core was able to perform the same way as old one. It means the cores share the configurations of that instance. If you are having 10 Solr instance, then only you have to make change for 10 instances.Bebe

© 2022 - 2024 — McMap. All rights reserved.