简体   繁体   中英

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

I'd like to delete index in elasticsearch 6.4.3 by using DeleteRequest API

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();

where "index" is the index name and id is the document id.

As per https://www.elastic.co/guide/en/elasticsearch/client/java-rest/6.4/java-rest-high-document-delete.html documentation, you need to pass 3 arguments. 2 argument should be "doc".

If you want to delete an index in Elastic Search, you need to use the Delete Index 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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM