Delete multiple documents from an Elasticsearch Index

:heavy_exclamation_mark: This post is older than a year. Consider some information might not be accurate anymore. :heavy_exclamation_mark:

This post demonstrates how to delete documents from an Index in Elasticsearch, that meet you search criteria of a query. You may have situations, that you are reporting to a wrong index. Therefore this post gives you an solution how you can clean up your index.

Following example deletes all documents from the default index, that has the type books.

vinh@cinhtau:/var/elasticsearch> curl -XDELETE 'http://localhost:9200/logstash-2016.02.10/_query' -d '
  "query": {
    "match": {
      "type": {
        "query": "books",
        "type": "phrase"

Keep in mind that, elasticsearch running in a cluster, has no problems with deleting multiple documents. In the past the API was crashing a single running instance of elasticsearch v1.x. In Elasticsearch 2 this functionality was reworked and outsource from the elasticsearch core. The Delete by query is in Elasticsearch 2.2 supported by the delete-by-query plugin and much more mature. To check for plugins just get the node information and check for the plugin. If it is installed it will be listed in the result.

Please remember the terms for blog comments.