creating shard in SOLR

一个人想着一个人 提交于 2020-01-25 21:37:27

问题


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


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/43679290/creating-shard-in-solr

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!