2

我目前的流程:

SolrServer solrServer = new HttpSolrServer(“http://localhost:8983/solr”)
SolrQuery parameters = new SolrQuery()
parameters.set("q", *:*)
QueryResponse response = solrServer.query(parameters)
SolrDocumentList list = response.getResults()

如何在一周的几天内使用多个网址执行此操作?(“http://localhost:8983/solr/Monday”) (“http://localhost:8983/solr/Tuesday”) (“http://localhost:8983/solr/Wednesday”) (“http:// /localhost:8983/solr/Thursday”) (“http://localhost:8983/solr/Friday”)

4

2 回答 2

1

通过使用DistributedSearch,您可以将查询发送到多个 url。假设您有以下核心:

http://localhost:8983/solr/Monday
http://localhost:8983/solr/Tuesday
http://localhost:8983/solr/Wednesday
http://localhost:8983/solr/Thursday
http://localhost:8983/solr/Friday

您可以通过如下更改代码在 SolrJ 中执行此操作。

SolrServer solrServer = new HttpSolrServer(“http://localhost:8983/solr/Monday”);
SolrQuery parameters = new SolrQuery();
parameters.set("q", *:*);
parameters.setParam("shards","localhost:8983/solr/Monday, localhost:8983/solr/Tuesday, localhost:8983/solr/Wednesday, localhost:8983/solr/Thursday, localhost:8983/solr/Friday");
QueryResponse response = solrServer.query(parameters);
SolrDocumentList list = response.getResults();
于 2012-12-04T09:07:08.947 回答
0

您可以使用LBHttpSolrServer类来使用多个网址。

例子:

SolrServer solr = new LBHttpSolrServer("http://localhost:8983/solr/Monday",
                "http://localhost:8983/solr/Tuesday");
于 2014-05-13T07:13:57.803 回答