使用solrj进行分布式搜索



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

我找不到这方面的任何文档。如果你发现/以前用过这个,请帮我。

假设您的碎片是:

"localhost:8983/solr"one_answers"localhost:7754/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);

最新更新