gpt4 book ai didi

java - 使用 CloudSolrClient 连接到 solrcloud 时出错

转载 作者:行者123 更新时间:2023-11-30 05:30:51 25 4
gpt4 key购买 nike

我尝试使用 solrj CloudSolrClient 连接到 solrCloud,但出现错误。

以前直接调用单个solr节点,现在切换到solrcloud。我已经尝试了在线文档中指定的各种不同的 url 格式。

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

当使用以下 zkHost 字符串时,我收到各种错误。

主机: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

http://host:2181

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)

主机: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)

http://host:2181/solr

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)

我需要更改什么才能使用 solrj CloudSolrClient 通过 Zookeeper 成功查询 solr?

我已成功从终端与 Zookeeper 实例进行通信。

$ 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

最佳答案

事实证明,solrurls 和 zkurls 都可以提供给 CloudSolrClient.Builder 。我通过使用 SolrClient solrClient = new CloudSolrClient.Builder(hosts, Optional.empty()).build(); 解决了上一个问题。它接受 zkUrls 而 CloudSolrClient.Builder(hosts).build()接受 solr URL

关于java - 使用 CloudSolrClient 连接到 solrcloud 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57600290/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com