gpt4 book ai didi

java - Elasticsearch - NoNodeAvailableException

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:56:59 25 4
gpt4 key购买 nike

尝试使用 ES 2 的 Java API 连接到 Elasticsearch 2 时出现以下错误。这是代码:

Settings settings = Settings.settingsBuilder().put("cluster.name", Receptor.clusterName).build();
TransportClient transportClient = TransportClient.builder().settings(settings).build();
Client c = null;
try {
c = transportClient.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(Receptor.es_ip), 9300));
} catch (UnknownHostException e) {
System.err.println(Util.getTimestampStr() + "UnknownHostException error.");
e.printStackTrace();
}

CreateIndexRequestBuilder createIndexRequestBuilder = c.admin().indices().prepareCreate(indexName);
createIndexRequestBuilder.addMapping(documentName, json);
createIndexRequestBuilder.execute().actionGet();

我能够在 transportClient.connectedNodes() 上获取我的 ES 节点,但是当我尝试添加新映射时,我遇到了 NoNodeAvailableException 异常。此代码适用于以前版本的 Elasticsearch。知道哪里出了问题吗?

NoNodeAvailableException[None of the configured nodes are available:
[]] at
org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:280)
at
org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:197)
at
org.elasticsearch.client.transport.support.TransportProxyClient.execute(TransportProxyClient.java:55)
at
org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:272)
at
org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:347)
at
org.elasticsearch.client.support.AbstractClient$IndicesAdmin.execute(AbstractClient.java:1177)
at
org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:85)
at
org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:59)

最佳答案

感谢 the post he linked,@AndreiStefan 解决了我的问题.解决方案非常简单:

network.bind_host: 0

谢谢你们。

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

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