简体   繁体   中英

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

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

Create a shard only when the size of collection is grown enough that is too large for a node, so split the collection adding a shard and finally relocate the shard on a different node.

While possible, I can't think of a situation where do this in Java would be a good idea.

It is way more complicated than just compose the http request and put it into a browser.

http://localhost:8983/solr/admin/collections?action=CREATESHARD&collection=testCollection&shard=shard2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM