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 ...

Get ElasticSearch Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.