簡體   English   中英

"如何在 elasticsearch(6.4.3) 中使用 deleteRequest API 刪除索引"

[英]how to delete index with deleteRequest API in elasticsearch(6.4.3)

我想使用 DeleteRequest API 刪除 elasticsearch 6.4.3 中的索引

但是 elastic.co 指南 3 個參數(索引、文檔、id)( https:\/\/www.elastic.co\/guide\/en\/elasticsearch\/client\/java-rest\/6.4\/java-rest-high-document-delete.html<\/a> )

我想使用 2 個參數來刪除索引(索引、文檔)

那么,有人幫我解決這個問題嗎?

DeleteRequest deleteRequest = new DeleteRequest(index);
DeleteResponse response = mClient.delete(deleteRequest, RequestOptions.DEFAULT);
DeleteRequest request = new DeleteRequest(
    "index",   
    "doc",     
    "id");
DeleteResponse deleteResponse = client.delete(request,RequestOptions.DEFAULT);
        return deleteResponse.getResult().name();

其中“ index”是索引名稱,id是文檔ID。

根據https://www.elastic.co/guide/zh-CN/elasticsearch/client/java-rest/6.4/java-rest-high-document-delete.html文檔,您需要傳遞3個參數。 2參數應為“ doc”。

如果要在 Elastic Search 中刪除索引,則需要使用刪除索引 API https:\/\/www.elastic.co\/guide\/en\/elasticsearch\/client\/java-rest\/6.4\/java-rest-high-delete -index.html<\/a>

這是基本示例,使用同步執行:

DeleteIndexRequest request = new DeleteIndexRequest(*IndexName*);
DeleteIndexResponse deleteIndexResponse = client.indices().delete(request, RequestOptions.DEFAULT);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM