dockersolrdocker-composesolr-schema

Add field to Solr when running in Docker?


I'm running Solr in Docker. I need to add some custom fields into schema. That would usually be done by the command similar to this one:

curl -X POST -H 'Content-type:application/json' --data-binary '{
  "add-field":{
     "name":"shelf",
     "type":"myNewTxtField",
     "stored":true },
  "add-field":{
     "name":"location",
     "type":"myNewTxtField",
     "stored":true },
  "add-copy-field":{
     "source":"shelf",
      "dest":[ "location", "catchall" ]}
}' http://localhost:8983/solr/gettingstarted/schema

but I've moved my Solr to Docker container and I have no idea how to do the same in docker-compose.yml.

My docker-compose.yml starts Solr using following command:

solr:
    image: "solr:7.3.1"
...
command: 'bash -e -c "
        precreate-core mycore;
        cp -r /opt/solr/server/solr/configsets/_default /opt/solr/server/solr/configsets/mycore;
        cp /tmp/myconf/solr-mapping.xml /opt/solr/server/solr/configsets/mycore/conf/;
        rm /opt/solr/server/solr/configsets/mycore/conf/managed-schema;
        solr-foreground;
      "'

Any suggestion how to do this will be appreciated!


Solution

  • Okay I figured out how to do this.

    I created schema.xml from default one And added field into it. Then I've copied this file to the container, and in the command I've copied my schema.xml into my core's conf folder.

    That did the job.