0
votes

Currently, I am using below piece of logic for every query to Solr using CloudSolrServer API of solrj library.

CloudSolrServer server = new CloudSolrServer(<zookeeper_quorum>);
server.connect();

Once I got the response, I am just closing the connection.

server.shutdown();

I know this is not the correct way as I shouldn't open connection for every search. I wanted to create a connection pool (thread pool) in my code and query Solr. But, just wondering whether Solr would have implemented a thread pool internally in SolrJ client library to support this usage. If so, how to control the number of threads here?

2

2 Answers

0
votes

You need not close the connection after every response.

Solrj internally uses load balancing to hit different cloud replicas. That is after you submit a request to Solrj. It does not allow to submit a batch of queries. Your idea to create a thread pool looks good.

-1
votes

I want to know why you need to shutdown solr ,if you want to one server use multi collection ,you can only use this code。you needn't shutdown solrserver

`server = getCloudSolrServer("127.0.0.1:2181");
 UpdateRequest request = new UpdateRequest();
 request.add(docList);
 request.setParam("collection", collection);
 UpdateResponse response = request.process(server);
 server.commit();`