Book Image

ElasticSearch Cookbook

By : Alberto Paro
Book Image

ElasticSearch Cookbook

By: Alberto Paro

Overview of this book

Table of Contents (20 chapters)
ElasticSearch Cookbook Second Edition
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

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:

  1. From a command line, we can execute a DELETE call:

    curl -XDELETE http://127.0.0.1:9200/myindex
    
  2. The result returned by ElasticSearch, if everything goes well, should be:

    {"acknowledged":true}
  3. If the index doesn't exist, then a...