0
votes

I have a use case that is to create a new core in Solr with new schema dynamically in a program without pre-creating the schema and configurations in instancedir.

I have tried using Solr Core Admin API by calling to:

~/admin/cores?action=CREATE&name=core-name&configSet=basic_configs

And managed to create a new core with the schema of the basic_configs.

However, later I realised that when I change the schema in that core, the respective changes will reflect to the schema of basic_configs as well (as configSet is a shared configuration). Hence, I could not reuse the same API call to create subsequent new cores with new schema.

I understand that this could be achieved using solr command to create cores but I would like to have it in REST API or SolrJ way.

Also, I am not using Solr in SolrCloud mode.

1

1 Answers

0
votes

You can give an explicit instanceDir when creating the core:

admin/cores?action=CREATE&name=core-name&instanceDir=path/to/dir&config=solrconfig.xml&dataDir=data

If there are no config sets, then the instanceDir specified in the CREATE call must already exist, and it must contain a conf directory which in turn must contain solrconfig.xml, your schema, which is usually named either managed-schema or schema.xml, and any files referenced by those configs.

The config and schema filenames can be specified with the config and schema parameters, but these are expert options. One thing you could do to avoid creating the conf directory is use config and schema parameters that point at absolute paths, but this can lead to confusing configurations unless you fully understand what you are doing.