0

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!

kodlan
  • 561
  • 8
  • 23

2 Answers2

0

in the /opt/solr/server/solr/configsets/_default/conf folder of the solr image there is a file managed-schema, it is an xml file but without extension.

you have to export from the original container with cp command:

docker cp [your_solr_container]:/opt/solr/server/solr/configsets/_default/conf/managed-schema c:/your_folder/managed-schema

so now you have the basic file, and you can add your new fields and passing into your docker container from docker compose:

version: '3.3'
    services:
      solr:
        image: "solr:7.3.1"
        ports:
         - "8983:8983"
        volumes:
          - ./managed-schema:/opt/solr/server/solr/configsets/_default/conf/managed-schema
        entrypoint:
          - docker-entrypoint.sh
          - solr-precreate
          - mycore
-2

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.

kodlan
  • 561
  • 8
  • 23