Giovanni Grano February 2016

Delete entire index in ElasticSearch

I'm approaching ElastichSearch with a Java client. I'm trying to delete an entire index. I'm able to delete a single document with the following code:

DeleteResponse response = client.prepareDelete("twitter", "tweet", "1").get();

I would like to delete all documents for a given index in a single instruction. Note that I'm using the version 2.2.

Thanks

EDIT: I've found a similar question but it refers to an old API version. I'm currently working with version 2.2.

Answers


maximede February 2016

The easiest way would be to delete your index, then recreate it.

DeleteIndexResponse deleteResponse = client.admin().indices().delete(new DeleteIndexRequest("your-index")).actionGet()

then

client.admin().indices().prepareCreate("your-index").get();

This will work with the 2.2 api

Post Status

Asked in February 2016
Viewed 1,952 times
Voted 8
Answered 1 times

Search




Leave an answer