Deleting an index
The counterpart of creating an index is deleting one. Deleting an index means deleting its shards, settings, 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 or obsolete data (for example, old Logstash indices).
- Resetting an index for a scratch restart.
- Deleting an index that has some missing shards, mainly due to some failures, to bring the cluster back to a valid state. (If a node dies and it's storing a single replica shard of an index, this index will be missing a shard, so the cluster state becomes red. In this case, you'll need to bring the cluster back to a green state, but you will lose the data contained in the deleted index.)
Getting ready
You will need an up-and-running Elasticsearch installation, as we described in the Downloading and installing Elasticsearch recipe of Chapter 1, Getting Started.
To execute the commands...