gpt4 book ai didi

java - 在 ElasticSearch API 应用程序中找不到 NodeBuilder

转载 作者:搜寻专家 更新时间:2023-10-31 20:32:57 24 4
gpt4 key购买 nike

我正在尝试实现 Elasticsearch API。我在系统接受 nodeBuilder 时遇到错误。这是代码-

import org.elasticsearch.action.index.IndexResponse;   
import org.elasticsearch.action.update.UpdateRequest;
import org.elasticsearch.client.Client;
//import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.*;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.node.NodeBuilder.*;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHit;



// on startup

Node node = nodeBuilder().node(); // nodeBuilder not recognised.
Client client = node.client();

// on shutdown

node.close();


<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>2.2.0</version>
</dependency>

客户被认可。有什么想法吗?

最佳答案

ClientBuilder 在 ES API 5 中被移除。

您可以使用 org.elasticsearch.common.settings.Settings.builder(),它将为您提供 Builder 的实例。

实验:

Settings.Builder elasticsearchSettings =
Settings.builder()
.put("http.enabled", "true")
.put("index.number_of_shards", "1")
.put("path.data", new File(tmpDir, "data").getAbsolutePath())
.put("path.logs", new File(tmpDir, "logs").getAbsolutePath())
.put("path.work", new File(tmpDir, "work").getAbsolutePath())
.put("path.home", tmpDir);

关于java - 在 ElasticSearch API 应用程序中找不到 NodeBuilder,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35342083/

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