使用Java高级Rest客户端删除索引自定义api



这是一个使用传输客户端和使用admin的import语句删除索引的自定义api,它工作得很好。

我正在使用Java高级Rest客户端编写相同的内容,但无法在那里找到适当的导入语句。根据我所读到的admin不用于Java高级Rest客户端,因为它似乎已被弃用。

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. indexes . createindexrequest是推荐的。

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

High Level Rest Client不可用吗?这两种输入似乎令人困惑。有人知道这两者的具体区别吗?

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

最新更新