• Home
  • LLMs
  • Docker
  • Kubernetes
  • Java
  • Maven
  • About
Apache Solr | Solr HTTP Admin API: Configsets API
  1. Notes
  2. List Configsets
  3. Upload a Configset
  4. Create a Configset
  5. Delete a Configset

  1. Notes
    See this page for more details about the Configsets API:
    https://solr.apache.org/guide/solr/latest/configuration-guide/configsets-api.html
  2. List Configsets
    • HTTP Request (URL):
      ► V1 API:
      http://localhost:8983/solr/admin/configs?action=List&omitHeader=true&wt=xml&indent=true

      ► V2 API:
      http://localhost:8983/api/cluster/configs?omitHeader=true&wt=xml&indent=true

      These parameters can be added to the request:
      • omitHeader=true

      • wt=json

      • indent=true

    • Java sample:
      private void listConfigSets(final int jettyPort) throws IOException {
          final String url = "http://localhost:"
                  + jettyPort
                  + "/solr/admin/configs?action=LIST";
      
          final HttpGet request = new HttpGet(url);
      
          try (final CloseableHttpClient client = HttpClientBuilder.create().build();
                  final CloseableHttpResponse response = client.execute(request)) {
              final HttpEntity entity = response.getEntity();
      
              System.out.println(IOUtils.toString(entity.getContent(), "UTF-8"));
      
              // close the content stream.
              EntityUtils.consumeQuietly(entity);
          }
      }
  3. Upload a Configset
    To upload a Configset, you need to prepare the zip file that has to be created from within a directory where the solr configuration files ("solrconfig.xml", ...) are directly located. Solr configuration files must be the top level entry in the zip file.

    Create the zip file:
    $ (cd /opt/solr/server/solr/configsets/_default/conf && zip -r - *) > /opt/solr/_defaultUploadedConfigSet.zip

    Upload the zip file and create a Configset:
    $ curl -X POST \
    --header "Content-Type:application/octet-stream" \
    --data-binary @/opt/solr/_defaultUploadedConfigSet.zip \
    "http://localhost:8983/solr/admin/configs?action=UPLOAD&name=_defaultUploadedConfigSet"

    You can use this command if you want to create and upload the zip file and create the Configset at the same time:
    $ (cd /opt/solr/server/solr/configsets/_default/conf && zip -r - *) | curl -X POST \
    --header "Content-Type:application/octet-stream" \
    --data-binary @- \
    "http://localhost:8983/solr/admin/configs?action=UPLOAD&name=_defaultUploadedConfigSet1"
  4. Create a Configset
    Create a new Configset ("configSetName") based on an existing Configset ("baseConfigSetName").

    The Configset can be created as immutable ("configSetProp.immutable=true"), which means it cannot be edited or deleted and its Schema cannot be updated by the Schema API.

    • HTTP Request (URL):
      ► V1 API:
      http://localhost:8983/solr/admin/configs?action=CREATE&name=_default1&baseConfigSet=_default&configSetProp.immutable=false

      ► V2 API:
      $ curl -X POST -H 'Content-type: application/json' \
      -d '{
        "create":{
          "name": "_default2",
          "baseConfigSet": "_default"
        }
      }' \
      http://localhost:8983/api/cluster/configs?configSetProp.immutable=false

    • Java sample:
      private void createConfigSet(final int jettyPort, final String configSetName, final String baseConfigSetName) throws IOException {
          final String url = "http://localhost:"
                  + jettyPort
                  + "/solr/admin/configs?action=CREATE"
                  + "&name=" + configSetName
                  + "&baseConfigSet=" + baseConfigSetName
                  + "&configSetProp.immutable=false";
      
          final HttpGet request = new HttpGet(url);
      
          try (final CloseableHttpClient client = HttpClientBuilder.create().build();
                  final CloseableHttpResponse response = client.execute(request)) {
              final HttpEntity entity = response.getEntity();
      
              System.out.println(IOUtils.toString(entity.getContent(), "UTF-8"));
      
              // close the content stream.
              EntityUtils.consumeQuietly(entity);
          }
      }
  5. Delete a Configset
    You will get an error if you try to delete a Configset that is used by collections.
    You have to delete those collections to be able to delete the Configset.

    • HTTP Request (URL):
      ► V1 API:
      http://localhost:8983/solr/admin/configs?action=DELETE&name=_default1

      ► V2 API:
      $ curl -X DELETE http://localhost:8983/api/cluster/configs/_default2

    • Java sample:
      private void deleteConfigSet(final int jettyPort, final String configSetName) throws IOException {
          final String url = "http://localhost:"
                  + jettyPort
                  + "/solr/admin/configs?action=DELETE"
                  + "&name=" + configSetName;
      
          final HttpGet request = new HttpGet(url);
      
          try (final CloseableHttpClient client = HttpClientBuilder.create().build();
                  final CloseableHttpResponse response = client.execute(request)) {
              final HttpEntity entity = response.getEntity();
      
              System.out.println(IOUtils.toString(entity.getContent(), "UTF-8"));
      
              // close the content stream.
              EntityUtils.consumeQuietly(entity);
          }
      }
© 2025  mtitek