gpt4 book ai didi

ElasticSearch 6 高级 Rest 客户端 preparePutMapping

转载 作者:行者123 更新时间:2023-12-03 00:02:14 27 4
gpt4 key购买 nike

我正在尝试从 ElasticSearch 2 过渡到 5 或 6。我想我想直接跳到 6.1.1 并使用 RestHighLevelClient,因为它比低级休息客户端更接近我正在使用的现有传输客户端.

但是,我遇到了一个问题作为集成测试的一部分,我正在创建索引并插入特定数据,因此我知道我的查询是正确的。我似乎无法在高级客户端中做到这一点。特别是,我希望能够调用:

  RestHighLevelClient client = new RestHighLevelClient(RestClient.builder(new HttpHost(host, port)))
client.indices()
.preparePutMapping(databaseName)
.setType(tableName).etc....

但是,client.indices() 返回一个没有 preparePutMapping() 的 org.elasticsearch.client.IndicesClient(来自 org.elasticsearch.client:elasticsearch-rest-high-level-client:6.1.1)。我需要一个 org.elasticsearch.client.IndicesAdminClient(来自 org.elasticsearch:elasticsearch:6.1.1)。我不知道如何从 RestHighLevelClient 或 RestClient 获得它。

我运气不好?这只是尚未实现的过渡阵痛吗?或者更永久的东西?

最佳答案

看着documentation :

client.admin().indices()
.preparePutMapping(databaseName)
.setType(tableName)
...

看起来您只需要一个额外的 .admin() .

关于ElasticSearch 6 高级 Rest 客户端 preparePutMapping,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48100631/

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