I'm trying to connect to solrCloud using solrj CloudSolrClient, but am getting errors.
Used to directly call a single solr node, now switching to solrcloud. I have tried various different url formats as specified from documentation online.
SolrClient solrClient = new CloudSolrClient.Builder(zkUrl).build();
SolrQuery solrQuery = new SolrQuery();
solrQuery.setRequestHandler(FIELD_LIST_HANDLER);
QueryRequest req = new QueryRequest(solrQuery);
req.setBasicAuthCredentials(zkUser, zkPassword);
QueryResponse response = req.process(solrClient, core);
When using the following zkHost strings I get the various errors.
host:2181
2019-08-21 15:53:17 - ERROR o.a.c.c.C.[.[.[.[.a.d.n.s.JerseyConfiguration] [http-nio-8080-exec-1] Servlet.service() for servlet [com.att.dplr.nextgen.search.JerseyConfiguration] in context with path [] threw exception [java.lang.RuntimeException: Couldn't init ialize a HttpClusterStateProvider (is/are the Solr server(s), [host:2181], down?)] with root cause org.apache.http.client.ClientProtocolException: URI does not specify a valid host name: host:2181/admin/collections?action=CLUSTERSTATUS&wt=javabin&version=2
2019-08-21 15:55:53 - ERROR o.a.c.c.C.[.[.[.[.a.d.n.s.JerseyConfiguration] [http-nio-8080-exec-1] Servlet.service() for servlet [com.att.dplr.nextgen.search.JerseyConfiguration] in context with path [] threw exception [java.lang.RuntimeException: Couldn't init ialize a HttpClusterStateProvider (is/are the Solr server(s), [http://host:2181], down?)] with root cause org.apache.http.NoHttpResponseException: host:2181 failed to respond at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:141)
host:2181/solr
2019-08-21 16:00:11 - ERROR o.a.c.c.C.[.[.[.[.a.d.n.s.JerseyConfiguration] [http-nio-8080-exec-1] Servlet.service() for servlet [com.att.dplr.nextgen.search.JerseyConfiguration] in context with path [] threw exception [java.lang.RuntimeException: Couldn't init ialize a HttpClusterStateProvider (is/are the Solr server(s), [host:2181/solr], down?)] with root cause org.apache.http.client.ClientProtocolException: URI does not specify a valid host name: host:2181/solr/admin/collections?action=CLUSTERSTATUS&wt=javabin&version=2 at org.apache.http.impl.client.CloseableHttpClient.determineTarget(CloseableHttpClient.java:95)
2019-08-21 15:57:23 - ERROR o.a.c.c.C.[.[.[.[.a.d.n.s.JerseyConfiguration] [http-nio-8080-exec-1] Servlet.service() for servlet [com.att.dplr.nextgen.search.JerseyConfiguration] in context with path [] threw exception [java.lang.RuntimeException: Couldn't init ialize a HttpClusterStateProvider (is/are the Solr server(s), [http://host:2181/solr], down?)] with root cause org.apache.http.NoHttpResponseException: host:2181 failed to respond at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:141)
What do I need to change to successfully query solr through zookeeper using solrj CloudSolrClient?
I have successfully communicated with the zookeeper instance from terminal.
$ echo stat | nc host 2181
Zookeeper version: 3.4.14-4c25d480e66aadd371de8bd2fd8da255ac140bcf, built on 03/06/2019 16:18 GMT
Clients:
/130.10.31.81:60381[0](queued=0,recved=1,sent=0)
/135.40.74.31:48984[1](queued=0,recved=817933,sent=817933)
Latency min/avg/max: 0/0/80
Received: 1893410
Sent: 1893706
Connections: 2
Outstanding: 0
Zxid: 0xa00000636
Mode: follower
Node count: 214
It turns out that both solrurls and zkurls can be provided to the CloudSolrClient.Builder
. I was able to get past the previous issue by using the SolrClient solrClient = new CloudSolrClient.Builder(hosts, Optional.empty()).build();
which accepts zkUrls whereas CloudSolrClient.Builder(hosts).build()
accepts solr Urls