# Delete document from elastic search

**URL:** <https://discuss.elastic.co/t/delete-document-from-elastic-search/105750>\
**Category:** Elasticsearch\
**Created:** [October 30, 2017, 11:11am UTC](https://discuss.elastic.co/t/delete-document-from-elastic-search/105750 "2017-10-30T11:11:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sumit\_Gupta1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sumit_gupta1/32/22861_2.png) [@Sumit\_Gupta1](https://discuss.elastic.co/u/Sumit_Gupta1)\
**Post date:** [October 30, 2017, 11:11am UTC](https://discuss.elastic.co/t/delete-document-from-elastic-search/105750/1 "2017-10-30T11:11:58Z")

</div>

Hi,

I want to delete some document which type is mytype1.

curl -XDELETE '[http://localhost:9200/logstash-databases-info/mytype1/\_query](http://localhost:9200/logstash-databases-info/mytype1/_query)' -d '{

> "query" : {  
> "match\_all" : {}  
> }  
> }'

This throwing following log:  
{"found":false,"\_index":"logstash-databases-info","\_type":"mytype1","\_id":"\_query","\_version":1,"\_shards":{"total":2,"successful":1,"failed":0}}

Can you please suggest this?

---

<div class="post-metadata">

**Author:** ![TimV](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timv/32/13162_2.png) [@TimV](https://discuss.elastic.co/u/TimV)\
**Post date:** [October 30, 2017, 11:35pm UTC](https://discuss.elastic.co/t/delete-document-from-elastic-search/105750/2 "2017-10-30T23:35:25Z")

</div>

It's looks like you are mixing up two different APIs.

There is the [Delete API](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/docs-delete.html) which deletes a specific document by id

```auto
curl -X DELETE 'http://localhost:9200/logstash-databases-info/mytype1/1'

```

And there is the [Delete By Query API](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/docs-delete-by-query.html) which deletes documents matching a query

```auto
curl -X POST 'http://localhost:9200/logstash-databases-info/mytype1/_delete_by_query -d '{ .... }'

```

Also, when posting on these forums, please include the version of Elasticsearch you are running, and take the time to format your post correctly (e.g. marking terminal commands as code blocks) using the buttons at the top of the editor window.

---

<div class="post-metadata">

**Author:** ![Sumit\_Gupta1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sumit_gupta1/32/22861_2.png) [@Sumit\_Gupta1](https://discuss.elastic.co/u/Sumit_Gupta1)\
**Post date:** [November 1, 2017, 6:45pm UTC](https://discuss.elastic.co/t/delete-document-from-elastic-search/105750/3 "2017-11-01T18:45:37Z")

</div>

Thanks Tim for reply.

I'm using Elasticsearch 2.3. I tried second API which is not working. is it correct?

This is compatible for Elasticsearch 2.3 ?

---

<div class="post-metadata">

**Author:** ![TimV](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timv/32/13162_2.png) [@TimV](https://discuss.elastic.co/u/TimV)\
**Post date:** [November 1, 2017, 11:51pm UTC](https://discuss.elastic.co/t/delete-document-from-elastic-search/105750/4 "2017-11-01T23:51:19Z")

</div>

In the future please include your Elasticsearch version in your post. Things change quite dramatically between releases and we will end up giving you the wrong advice if we guess the wrong version.

The documentation for delete-by-query in 2.3 is here: [https://www.elastic.co/guide/en/elasticsearch/plugins/2.3/plugins-delete-by-query.html](https://www.elastic.co/guide/en/elasticsearch/plugins/2.3/plugins-delete-by-query.html)

---

<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:** [November 29, 2017, 11:52pm UTC](https://discuss.elastic.co/t/delete-document-from-elastic-search/105750/5 "2017-11-29T23:52:06Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
