我目前的流程:
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://本地主机:8983 / Solr的/星期一”) (“HTTP://本地主机:8983 / Solr的/星期二”) (“HTTP://本地主机:8983 / Solr的/星期三”) (“HTTP://本地主机:8983 / solr的/星期四”) (“HTTP://本地主机:8983 / solr的/星期五”)
答案 0 :(得分:1)
通过使用DistributedSearch,您可以向多个网址发送查询。假设您有以下核心:
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
您可以通过更改代码在Solr中执行此操作。
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();
答案 1 :(得分:0)
您可以使用LBHttpSolrServer
类来使用多个网址。
示例:
SolrServer solr = new LBHttpSolrServer("http://localhost:8983/solr/Monday",
"http://localhost:8983/solr/Tuesday");