Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Distributed search using solrj?

Tags:

solr

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.

like image 572
Greenhorn Avatar asked Feb 22 '23 04:02

Greenhorn


1 Answers

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);
like image 52
stzoannos Avatar answered Mar 07 '23 07:03

stzoannos