Hi,

I have a use-case where Java applications need to create Solr indexes dynamically. Schema fields of these indexes differ and should be defined by the Java application upon creation.

So I'm trying to use the Core Admin API [1] to create new cores and the Schema API [2] to define fields. When creating a core, I have to specify solrconfig.xml (with enabled ManagedIndexSchemaFactory) and the schema to start with. I thought it would be a good idea to use a named config sets [3] for this purpose:

curl 'http://localhost:8082/solr/admin/cores?action=CREATE&name=m1&instanceDir=cores/m1&configSet=myconfig&dataDir=data'

But when I add a field to the core "m1", the field actually gets added to the config set. Is this a bug of feature?

curl http://localhost:8082/solr/m1/schema/fields -X POST -H 'Content-type:application/json'
  --data-binary '[{
        "name":"foo",
        "type":"tdate",
        "stored":true
    }]'

All cores created from the config set "myconfig" will get the new field "foo" in their schema. So this obviously does not work to create cores with different schema.

I also tried to use the config/schema parameters of the CREATE core command (instead of config sets) to specify some existing solrconfig.xml/schema.xml. I tried relative paths here (e.g. some level upwards) but I could not get it to work. The documentation [1] tells me that relative paths are allowed. Should this work?

Next thing that would come to my mind is to use dynamic fields instead of a correct managed schema, but that does not sound as nice. Or maybe I should implement a custom CoreAdminHandler which takes list of field definitions, if that's possible somehow...?

I don't know. What's your recommended approach?

We're using Solr 4.10.1 non-SolrCloud. Would this be simpler or different with SolrCloud?

Thank you,
Andreas

[1] https://cwiki.apache.org/confluence/display/solr/CoreAdmin+API#CoreAdminAPI-CREATE [2] https://cwiki.apache.org/confluence/display/solr/Schema+API#SchemaAPI-Modifytheschema
[3] https://cwiki.apache.org/confluence/display/solr/Config+Sets

Reply via email to