Can somebody help, please? I don't think my use-case is so uncommon.

I read this JIRA comment where the idea of using config sets as templates was brought up
https://issues.apache.org/jira/browse/SOLR-4478?focusedCommentId=13711098&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13711098
This would have been a perfect fit for me but it seems the idea got rejected.

Thank you,
Andreas

Andreas Hubold wrote on 11/06/2014 04:04 PM:
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
.



--
Andreas Hubold
Software Architect

tel     +49.40.325587.519
fax     +49.40.325587.999
andreas.hub...@coremedia.com

CoreMedia AG
content | context | conversion

Ludwig-Erhard-Str. 18
20459 Hamburg, Germany
www.coremedia.com

Executive Board: Gerrit Kolb (CEO), Dr. Klemens Kleiminger (CFO)
Supervisory Board: Prof. Dr. Florian Matthes (Chairman)
Trade Register: Amtsgericht Hamburg, HR B 76277

Reply via email to