gpt4 book ai didi

java - Elasticsearch NoNodeAvailableException 配置的节点均不可用

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:31:40 26 4
gpt4 key购买 nike

Settings settings = Settings.settingsBuilder()
.put("cluster.name", "logging_elasticsearch")
.build();
TransportClient client = TransportClient.builder()
.settings(settings)
.build()
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByAddress(new byte[]{10,100,30,62}), 9300));

SearchResponse response = client.prepareSearch("logstash-2016.09.08")
.setTypes("type1", "type2")
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
.setQuery(QueryBuilders.termQuery("multi", "test")) // Query
.setPostFilter(QueryBuilders.rangeQuery("age").from(12).to(18)) // Filter
.setFrom(0).setSize(60).setExplain(true)
.execute()
.actionGet();

elasticsearch.yml我在执行搜索查询时遇到了 NoNodeAvailableException

我试过这个解决方案: https://stackoverflow.com/a/33875764/2616923 但它没有用。

最佳答案

尝试这种方式,您的代码似乎非常接近:

Settings settings = Settings.settingsBuilder()
.put("cluster.name", "<elasticsearch-cluster-name>")
.build();

Client client = new TransportClient.Builder()
.settings(settings)
.build()
.addTransportAddress(new InetSocketTransportAddress(new InetSocketAddress("<elasticsearch-network-host>", <elasticsearch-transport-client-port|default 9300>)));

==== elasticsearch.yml ====

cluster.name: <elasticsearch-cluster-name>
node.name: <elasticsearch-network-host>
network.host: <elasticsearch-network-host>
network.bind_host: 0

关于java - Elasticsearch NoNodeAvailableException 配置的节点均不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39455913/

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