creating shard in SOLR

2019-09-18 20:26发布

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

标签: java solr solrj
2条回答
Explosion°爆炸
2楼-- · 2019-09-18 20:51

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

查看更多
戒情不戒烟
3楼-- · 2019-09-18 21:11

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

查看更多
登录 后发表回答