使用solrj的分布式搜索?

使用solrj的分布式搜索?,solr,solrj,Solr,Solrj,我可以使用solrj执行分布式搜索吗?如果是,怎么做?(注:非solr) 我找不到这方面的任何文档。如果您发现/曾经使用过此功能,请帮助我。假设您的碎片是: “localhost:8983/solr”和“localhost:7574/solr” 您可以使用solrj执行分布式搜索,如: String shards = "localhost:8983/solr,localhost:7574/solr"; StringBuffer request = new StringBuffer(); requ

我可以使用solrj执行分布式搜索吗?如果是,怎么做?(注:非solr)


我找不到这方面的任何文档。如果您发现/曾经使用过此功能,请帮助我。

假设您的碎片是:

“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);
或者,您可以使用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);

但使用solr4j意味着您需要一个HttpSolrClient对象,在本例中,我假定它是服务器。你是如何创造它的?(我有solr 5.3.0)