gpt4 book ai didi

java - ElasticSearch GetApi NoNodeAvailableException

转载 作者:太空宇宙 更新时间:2023-11-04 11:18:44 25 4
gpt4 key购买 nike

我尝试使用https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-docs-get.html , Elasticsearch 文档,从我刚刚创建的索引中获取文档

我的整个代码是:

TransportClient client = new PreBuiltTransportClient(Settings.EMPTY)
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("127.0.0.1"), 9300));
GetResponse response = client.prepareGet("twitter", "tweet", "1").get();

我收到以下异常(当我到达“get”行时):

NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{dUtRDm92Tg6ob6GVMtbgWA}{127.0.0.1}{127.0.0.1:9300}]]
at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:347)
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:245)
at org.elasticsearch.client.transport.TransportProxyClient.execute(TransportProxyClient.java:59)
at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:363)
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:408)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:80)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:54)
at org.elasticsearch.action.ActionRequestBuilder.get(ActionRequestBuilder.java:62)
at

我搜索了答案并得到了以下解决方案:

我使用的是相同版本的elasticsearch 5.5.0 Elasticsearch NoNodeAvailableException

给出集群的名称(如果在elasticsearch.yml中更改) Java ElasticSearch None of the configured nodes are available NoNodeAvailableException : None of the configured nodes are available

另一个解决方案是端口 - 使用 9200-9300、9300-9400并尝试使用 client.transport.sniff 选项 Java ElasticSearch None of the configured nodes are available

另一个解决方案是将 network.bind_host: 0 添加到 yml - How to bind Elasticsearch 2.0 on both Loopback and Non-Loopback interfaces?

我的防火墙已关闭

这些解决方案都不适合我。这应该非常简单,并且 Elasticsearch 安装是全新的。我错过了什么?

最佳答案

分享你完整的java代码。 Elasticsearch 使用两个端口。端口 9200 提供通过 http 的访问(例如您的浏览器)。端口 9300 用于通过内部传输协议(protocol)访问 Elasticsearch,该协议(protocol)由 Java 传输客户端使用。检查您的防火墙设置,可能是防火墙阻止了端口。

关于java - ElasticSearch GetApi NoNodeAvailableException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45171826/

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