gpt4 book ai didi

java - NoNodeAvailableException : None of the configured nodes are available

转载 作者:搜寻专家 更新时间:2023-11-01 01:40:46 24 4
gpt4 key购买 nike

我正在尝试从我的 Java Web 服务中的 Elastic Search 进行搜索,这是我现在的使用方式:

    Client client = new PreBuiltTransportClient(Settings.EMPTY).addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("192.168.10.150"), 9200));
SearchResponse searchResponse = client.prepareSearch().execute().actionGet();

第一行可以正常运行,但是当进入第二行时,会出现下面的异常:

NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{TskPSVeBRR6CvCzP9EVhkQ}{192.168.10.150}{192.168.10.150:9200}]]

无论我用9200还是9300设置端口,结果都是一样的。

另外,我尝试使用 NEST 从我的 .Net 程序中搜索,它运行得很好。这是我的尝试:

    var node = new Uri("http://192.168.10.150:9200");
var settings = new ConnectionSettings(node).DefaultIndex("iod-2017.03.08.*");
_EsClient = new ElasticClient(settings);
var index = String.Format("iod-{0}.{1:00}.{2:00}.*", item.TriggerTime.Year, item.TriggerTime.Month, item.TriggerTime.Day);
var uniqueId = item.UniqueId.ToString();
var result = _EsClient.Search<logs>(s => s.Index(index).Query(q => q.Match(t => t.Field(l => l.id).Query(uniqueId))));

我的 Java 程序是否有任何错误(防火墙、库的版本、调用 API 的方法等)?我目前的Java版本是1.8.0.121Elastic SearchTransport Client的版本都是 5.2 。谢谢!

最佳答案

正如评论中所讨论的,

如果您使用的集群名称不是 elasticsearch,那么您需要在设置中更新相同的名称。

Settings settings = Settings.builder()
.put("cluster.name", "myClusterName").build();

关于java - NoNodeAvailableException : None of the configured nodes are available,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42826735/

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