20
votes

Is it possible to create new cores in SOLR via HTTP? I can't seem to find a definitive answer to what seems like a very simple question...

Each core I want to create will have the same schema/configuration (multi-tenant SaaS architecture).

I found this page:

Which makes me think it's possible, but it's not very clear on specifically what each parameter I'm supposed to pass in actually is:

  • instanceDir - is this the path to where I want the new core to reside, or where the existing "template" core resides? is it a full file path, or a relative one? relative to what?

  • config - is this a full file path to the existing config file? or a relative one? relative to what?

  • schema - same as above

  • dataDir - is this the data dir of the existing core, or the new one? full file path? relative? relative to what? does it already have to exist, or will SOLR create it for me?

3
In my experience (and confirmed on the solr-user listserv), you cannot create a new core over HTTP. Yes, there's an API for it, but the API assumes you've already created the conf directory and put the right files in it, which cannot be done over HTTP: you must have file system acccess. The "config sets" feature may be a way around this, but it didn't work as advertised for me and when I asked on solr-user, the response was, "it's new and still buggy, so we're not surprised that it doesn't work."Mark E. Haase
This does work, I have marked the working answer below as accepted now. We've been using this in production for quite some time now with great success.Keith Palmer Jr.
Keith, are you using the "Solr Cloud" configuration (i.e. with ZooKeeper) or a single-node Solr instance?Mark E. Haase
Single node instance.Keith Palmer Jr.
@Keith. I seems as if I'm facing now the same problem as you. Can you, please, share with us the right answer: http://what should be here??? Since buddy86's answer with http://'localhost':8983... does not look right at first glance.Jacobian

3 Answers

10
votes

Yes, you can create the Solr cores via HTTP. You have found the correct URL (https://wiki.apache.org/solr/CoreAdmin) to look into. All the above parameters are optional.

instanceDir - This is the path where your new core will be created. It'll create the folder structure provided by you, under "/example/solr/". If you don't provide this parameter, it'll automatically create a new core (with the collection no) like collection1.

config - If you want to have a different solrconfig.xml for the new core, then provide this. Otherwise, it'll share the existing core's (collection1) config by default.

schema - If you want to have a different schema.xml for the new core, then provide this. Otherwise, it'll share the existing core's (collection1) schema by default.

dataDir - This is the path where your new core's data will be stored. It'll create the folder structure provided by you under the new core folder.

If you really don't want some different configuration for your new core, follow the sample HTTP URL

http://localhost:8983/solr/admin/cores?action=CREATE&name=core_name&numShards=2&replicationFactor=2

Hope this will help.

6
votes

I had the exact same issue and I was not able to make it work from the description on https://wiki.apache.org/solr/CoreAdmin#CREATE

What solved it for me was updating to Solr 5 and using a configSet (introduced in 4.8) which defines the shared solrconfig/schema. The following URL can be used to create several cores with the same configuration:

http://localhost:8983/solr/admin/cores?action=CREATE&name=new_core&configSet=basic_configs

The 'basic_configs' is the name of a configSet that comes with the Solr 5 download (solr-5.0.0/server/solr/configsets/basic_config). The URL worked out-of-the-box after starting the Solr server.

https://cwiki.apache.org/confluence/display/solr/Config+Sets

0
votes

Copy the configsets folder recursively to var/solr/data/your_new_core_name then add the your_new_core_name from the admin panel

The configsets path usually should be here.

/solr-8.6.3/server/solr/configsets/_default/conf