# Deleting all document from an index type

**URL:** <https://discuss.elastic.co/t/deleting-all-document-from-an-index-type/43111>\
**Category:** Elasticsearch\
**Created:** [March 1, 2016, 11:58am UTC](https://discuss.elastic.co/t/deleting-all-document-from-an-index-type/43111 "2016-03-01T11:58:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chalapathi](https://avatars.discourse-cdn.com/v4/letter/c/41988e/32.png) [@chalapathi](https://discuss.elastic.co/u/chalapathi)\
**Post date:** [March 1, 2016, 11:58am UTC](https://discuss.elastic.co/t/deleting-all-document-from-an-index-type/43111/1 "2016-03-01T11:58:23Z")

</div>

How to delete all documents from an indextype, i have tried multiple options of DELETE using sense tool.

I can delete record by record specifying id, but not all, can anyone tell me is this requires any plugin for ES 2.1.0.

Thanks,  
Chala

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [March 1, 2016, 2:30pm UTC](https://discuss.elastic.co/t/deleting-all-document-from-an-index-type/43111/2 "2016-03-01T14:30:31Z")

</div>

Hi,

you can use the [delete-by-query plugin](https://www.elastic.co/guide/en/elasticsearch/plugins/master/plugins-delete-by-query.html) for that. Here's an example:

We create an index with two types and add some documents:

```auto
POST /_bulk
{"index":{"_index":"mammals","_type":"people"}}
{"tag_line":"I am Mike"}
{"index":{"_index":"mammals","_type":"people"}}
{"tag_line":"I am Hanna"}
{"index":{"_index":"mammals","_type":"people"}}
{"tag_line":"I am Bert"}
{"index":{"_index":"mammals","_type":"animals"}}
{"tag_line":"I am a dog"}
{"index":{"_index":"mammals","_type":"animals"}}
{"tag_line":"I am a cat"}

```

When we query for all documents, we get 5 results:

```auto
GET /mammals/_search?size=0
{
    "query": {
        "match_all": {}
    }
}

```

Now we can delete all documents of the type "animals":

```auto
DELETE /mammals/animals/_query
{
    "query": {
        "match_all": {}
    }
}

```

This will only work when the delete-by-query plugin is installed.

When we search once again for all documents, we only get 3 results as the animals are gone.

Daniel

---

<div class="post-metadata">

**Author:** ![chalapathi](https://avatars.discourse-cdn.com/v4/letter/c/41988e/32.png) [@chalapathi](https://discuss.elastic.co/u/chalapathi)\
**Post date:** [March 3, 2016, 6:48am UTC](https://discuss.elastic.co/t/deleting-all-document-from-an-index-type/43111/3 "2016-03-03T06:48:37Z")

</div>

Thanks Daniel, after installing delete-by-query plugin its working.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:11pm UTC](https://discuss.elastic.co/t/deleting-all-document-from-an-index-type/43111/4 "2017-07-05T23:11:45Z")

</div>


