Shawn,
On 6/1/22 15:18, Shawn Heisey wrote:
On 6/1/2022 11:41 AM, Christopher Schultz wrote:
How can I provide the schema for the core once it's been created? Can
I use the API for that, or do I have to resort to pushing the config
file directly similar to these kindx of curl commands:
curl -d "{ ... config }" \
${SCHEME}://localhost:${PORT}/solr/${CORENAME}/config
curl -H application/json --data-binary '{ ... schema ... }' \
"${SCHEME}://localhost:${PORT}/solr/${CORENAME}/schema"
There's a chicken and egg problem. You can't use those endpoints until
the core is created. And you can't create the core without providing
the config and schema.
https://solr.apache.org/guide/8_9/coreadmin-api.html#coreadmin-create
(the large WARNING box in this section of the docs is the part I am
referring you to)
I'll have a look.
Assuming you're not going to be using cloud mode (in which case all
configs are in zookeeper) you have two choices: Create the core
directory with a conf subdirectory that contains a config and a schema
before calling the CoreAdmin API, or use the ConfigSets feature.
https://solr.apache.org/guide/8_9/config-sets.html#configsets-in-standalone-mode
When I used the CoreAdminRequest as suggested by Clemens, the Solr
server did create the core directory, but it's empty and I got that error.
Would it not be theoretically possible to accept the core-name and
config and schema all at once and provision the whole thing? This seems
like a big missing feature after 9 major versions. Maybe Solr standalone
is only for children :)
My notes for creating the core include:
$ sudo -u solr ${SOLR_HOME}/bin/solr create -c [corename]
I've never tried to do that from a remote server, but I don't specify a
config file or a schema in that command, and it works. Of course, I get
this warning:
WARNING: Using _default configset with data driven schema functionality.
NOT RECOMMENDED for production use.
My next steps are to provide a small config and a schema using two
separate curl commands, which obviously only communicate over the REST API.
What magic is "solr create" performing that I can't use via the API? OR
can I simulate it in some way?
Checking SolrJ, you would use createCore("corename", "corename", client)
if go you with the first option and name the directory "corename" in the
solr home. It doesn't look like CoreAdminRequest has a convenience
method for using a configSet when creating a core.
I worked out how to do it as a generic request with SolrJ if you want to
use the configsets feature:
https://paste.elyograg.org/view/3cd9aac2
Cool, though this is basically using SolrClient as an HttpClient ;)
Would this work with configSet=_default ? It would be great if I didn't
have to prepare a Solr installation other than making sure it's running
before my application is able to create cores.
Thanks,
-chris