Deleting an index
The counterpart of creating an index is deleting one.
Deleting an index means deleting its shards, mappings, and data. There are many common scenarios where we need to delete an index, such as the following:
- Removing the index to clean unwanted/obsolete data (for example, old logstash indices)
- Resetting an index for a scratch restart
- Deleting an index that has some missing shard, mainly due to some failure, to bring back the cluster to a valid state
Getting ready
You will need a working ElasticSearch cluster and the existing index created in the previous recipe.
How to do it...
The HTTP method used to delete an index is DELETE.
The URL contains only the index name:
http://<server>/<index_name>
To delete an index, we will perform the following steps:
- From a command line, we can execute a DELETE call:
curl -XDELETE http://127.0.0.1:9200/myindex
- The result returned by ElasticSearch, if everything goes well, should be:
{"acknowledged":true}
- If the index doesn't...