简体   繁体   中英

Distributed search using solrj?

Can I perform a distributed search using solrj? If so how? (note : not solr)

I don't find any documentation in this aspect. Kindly help me if you find any/have used this before.

Assuming that your shards are:

"localhost:8983/solr" and "localhost:7574/solr"

You may perform a distributed search with solrj like:

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);

alternatively, you may use the ModifiableSolrParams class:

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM