solrsolrjsolrcloud

Create CloudSolrClient using solr endpoint


Can I create a cloudsolrclient without using zookeeper? i dont want to add dependencies on zookeeper and directly talk to solrcloud.

this is my current code.. here endpoint is that of zookeeper. I tried giving solr url but it throws exception saying "Couldn't initialize a HttpClusterStateProvider (is/are the Solr server(s) is/are down"

CloudSolrClient.Builder builder = new Builder(Arrays.asList(endpoint)); return builder.build();

UPDATE :

used HttpSolrClient to create a client and was successfull. But not able to do any operations with it like listing all collections or create a collection. im using

List<String> collections = CollectionAdminRequest.listCollections(client);

is this wrong?


Solution

  • If you don't want to use Zookeeper, don't create a CloudSolrClient, but use a regular HttpSolrClient or LBHttpSolrClient instead.

    The Solr node you're connecting to will route the request internally to the host that has the data that you're requesting (i.e. it'll do the job that your CloudSolrClient would do for you).

    The gain by using CloudSolrClient is that it'll connect directly to the node hosting your collection, instead of having to go through a potentially non-hosting client and thus get your answer faster without an additional request inside your Solr cluster.