Search code examples
javasolrsolrj

creating shard in SOLR


I am new to Apache Solr. I have created a new Collection, named testCollection. This collection has been created through solr admin console and its router type is implicit. I am using the below code to create a new shard to the above collection

SolrServer solr = new HttpSolrServer("http://localhost:8983/solr/testCollection");

        UpdateRequest request = new UpdateRequest();
        request.setPath("http://localhost:8983/solr/testCollection");
        request.setMethod(METHOD.GET);
        request.setParam("action", "CREATESHARD");
        request.setParam("collection", "testCollection");
        request.setParam("shard", "latestShard");
        solr.request(request);
        solr.commit();

on executing the above I do not get any exception, but no new shard is created. I am using solr 6.1. Although this question might seem a possible duplicate of Solr 4 - adding shard but no code snippet is available, also how to achieve this using SolrJ is not mentioned. Any help will be appreciated.

Regards, Ankur


Solution

  • You are using the wrong api.

    The UpdateRequest is for performing actions on the index data (adding/deleting docs etc), not for managing how the collection is set up, for creating a shard for example, you need to use this