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 when we need to delete an index. Some of them are as follows:
- Removing it because the data that it contains is not needed anymore
- Reset an index for a scratch restart
- Delete an index that has some missing shard due to some failure to bring back the cluster in a valid state
Getting ready
You 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, which is as follows:
http://<server>/<index_name>
For deleting an index, we need to perform the following steps:
- From command line, we can execute a DELETE call as follows:
curl -XDELETE http://127.0.0.1:9200/myindex
- The result returned by ElasticSearch, if everything is all right, should be as follows:
{"ok":true,"acknowledged...