0

这是一个自定义 api,用于使用传输客户端删除索引和使用 admin 的导入语句,它工作正常。

我正在使用 Java High Level Rest Client 编写相同的内容,但无法在那里找到适当的导入语句。根据我读过的内容,admin 不能用于 Java High Level Rest Client,因为它似乎已被弃用。

import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse;

public IndexResponse deleteIndex(String index){
     DeleteIndexResponse response = client.admin().indices().prepareDelete(index).get();
}

使用 High Level Rest Client 时应该使用新的导入。我可以用它创建索引,但找不到删除请求或响应的相同导入。

import org.elasticsearch.client.indices.CreateIndexRequest;
public IndexResponse createIndexWithCustomMappings(String indexName, String fieldsMapping){
   CreateIndexResponse createIndexResponse = client.indices().create(request, RequestOptions.DEFAULT);}

import org.elasticsearch.client.indices.CreateIndexRequest 是推荐的一种。

我已经浏览了此文档https://www.elastic.co/guide/en/elasticsearch/client/java-rest/master/java-rest-high-delete-index.html#,但找不到任何相关内容对此。

这是否不适用于高级休息客户端。这两个进口似乎令人困惑。有人知道这两者之间的具体区别是什么吗?

4

1 回答 1

0

查看索引生命周期javadoc。您可能可以使用DeleteAction.

于 2021-09-24T09:24:13.590 回答