使用solrj进行分布式搜索?

Gre*_*orn 4 solr solrj

我可以使用solrj执行分布式搜索吗?如果是这样的话?(注意:不是solr)

我在这方面没有找到任何文件.如果你发现之前已经使用过这个,请帮助我.

小智 8

假设你的碎片是:

"localhost:8983/solr"和"localhost:7574/solr"

您可以使用solrj执行分布式搜索,例如:

String shards = "localhost:8983/solr,localhost:7574/solr";
StringBuffer request = new StringBuffer();
request.append("&q=" + query);
request.append("&shards=" + shards);
SolrParams solrParams = SolrRequestParsers.parseQueryString(request
                .toString());
QueryResponse rsp = server.query(solrParams);
Run Code Online (Sandbox Code Playgroud)

或者,您可以使用ModifiableSolrParams类:

String shards = "localhost:8983/solr,localhost:7574/solr";
ModifiableSolrParams solrParams = new ModifiableSolrParams();
solrParams.set("q", query);
solrParams.set("shards", shards);
QueryResponse rsp = server.query(solrParams);
Run Code Online (Sandbox Code Playgroud)