How to Delete Index in Elastic Search?

Connect with

elastic search
When you get chance to delete either documents or type or index , do it very carefully. How to delete index in elastic search is a straight forward but do this very carefully, specially in production environment. In this post I tried to demonstrate how to delete index and its indexed content in elastic search.

You can delete using cURL or visually using one of the many tools that open source enthusiasts have created for Elastic search. e.g. using head plugin, using fiddler, using rest client, using postman rest client or any another.

By end of this post you can learn following.

  • how to delete Index by index name in elastic search?
  • how to delete by type in elastic search?
  • how to delete more than one index by using wildcard (*)?
  • how to delete index by using Rest Client ?

Delete Index By Using cURL

Note: here , after port number (9200) , location which is an index name of elastic and restro is type, which comes under index name “location” and at end of the path param a document id.

You get reply from curl output as to whether this was successful or not.

Delete by type in Elastic

Delete by type by leaving documentID in the url.

curl -XDELETE localhost:9200/location/restro

Delete Index by index name

In the below query location is name of index, which delete all the index data from location index. Once you delete index , it means you deleted all of associated type under that index, do it very carefully.

curl -XDELETE [your_host]:9200/[your_index]

for example;

curl -XDELETE localhost:9200/location

Delete more than one index by using wildcard (*)

do this very carefully because of using wildcard option to delete index in elastic search.

curl -XDELETE localhost:9200/.oca* 

Delete Index By Using Rest Client

Service Input:

  1. Service URL: http://localhost:9200/myindex
  2. http method : Delete
  3. Content-Type: application/json

Service Output:

  1. Http response: 200 Ok
  2. JSON output
"acknowledged": true

Once deleted and you are trying to access again, you can get following error

            "reason":"no such index",
      "reason":"no such index",

Write your suggestions here to improve this post.

Connect with

2 thoughts on “How to Delete Index in Elastic Search?

  1. Pingback: Anu
  2. Pingback: rakhi

Leave a Reply

Your email address will not be published. Required fields are marked *