# Deleting document by query

**URL:** <https://discuss.elastic.co/t/deleting-document-by-query/318570>\
**Category:** Elasticsearch\
**Created:** [November 9, 2022, 4:52pm UTC](https://discuss.elastic.co/t/deleting-document-by-query/318570 "2022-11-09T16:52:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sssamant](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@sssamant](https://discuss.elastic.co/u/sssamant)\
**Post date:** [November 9, 2022, 4:52pm UTC](https://discuss.elastic.co/t/deleting-document-by-query/318570/1 "2022-11-09T16:52:19Z")

</div>

I am trying to use delete\_by\_query to delete some documents for a particular index. But it fails with illegal version value and I read that delete\_by\_query cannot be used to delete documents with index version zero. Is there any particular reason why is it so? And also is there any way to delete documents with index version zero as I can't delete the entire index. This is in production and high priority.

Error:  
Validation Failed: 1: illegal version value [0] for version type [INTERNAL];

Request to help. Thanks in advance.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [November 9, 2022, 10:52pm UTC](https://discuss.elastic.co/t/deleting-document-by-query/318570/2 "2022-11-09T22:52:05Z")

</div>

Please share the query you are running and the full output from Elasticsearch.

> [@sssamant](#):
>
> This is in production and high priority.

We don't provide SLAs here, but we do our best 🙂

---

<div class="post-metadata">

**Author:** ![sssamant](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@sssamant](https://discuss.elastic.co/u/sssamant)\
**Post date:** [November 14, 2022, 4:25pm UTC](https://discuss.elastic.co/t/deleting-document-by-query/318570/3 "2022-11-14T16:25:50Z")

</div>

curl -X POST "localhost:9200/my-index-000001,my-index-000002/\_delete\_by\_query?pretty" -H 'Content-Type: application/json' -d'  
{  
"query": {  
"match\_all": {}  
}  
}  
'

------------------------- Error while deleting

"error": {

"root\_cause": [

{

"type": "action\_request\_validation\_exception",

"reason": "Validation Failed: 1: illegal version value [0] for version type [INTERNAL];2: illegal version value [0] for version type [INTERNAL];3: illegal version value [0] for version type [INTERNAL];4: illegal version value [0] for version type [INTERNAL];5: illegal version value [0] for version type [INTERNAL];6: illegal version value [0] for version type [INTERNAL];7: illegal version value [0] for version type [INTERNAL];8: illegal version value [0] for version type [INTERNAL];9: illegal version value [0] for version type [INTERNAL];10: illegal version value [0] for version type [INTERNAL];11: illegal version value [0] for version type [INTERNAL];12: illegal version value [0] for version type [INTERNAL];13: illegal version value [0] for version type [INTERNAL];14: illegal version value [0] for version type [INTERNAL];15: illegal version value [0] for version type [INTERNAL];16: illegal version value [0] for version type [INTERNAL];17: illegal version value [0] for version type [INTERNAL];18: illegal version value [0] for version type [INTERNAL];19: illegal version value [0] for version type [INTERNAL];20: illegal version value [0] for version type [INTERNAL];21: illegal version value [0] for version type [INTERNAL];22: illegal version value [0] for version type [INTERNAL];23: illegal version value [0] for version type [INTERNAL];24: illegal version value [0] for version type [INTERNAL];25: illegal version value [0] for version type [INTERNAL];26: illegal version value [0] for version type [INTERNAL];27: illegal version value [0] for version type [INTERNAL];"

}

],

"type": "action\_request\_validation\_exception",

"reason": "Validation Failed: 1: illegal version value [0] for version type [INTERNAL];2: illegal version value [0] for version type [INTERNAL];3: illegal version value [0] for version type [INTERNAL];4: illegal version value [0] for version type [INTERNAL];5: illegal version value [0] for version type [INTERNAL];6: illegal version value [0] for version type [INTERNAL];7: illegal version value [0] for version type [INTERNAL];8: illegal version value [0] for version type [INTERNAL];9: illegal version value [0] for version type [INTERNAL];10: illegal version value [0] for version type [INTERNAL];11: illegal version value [0] for version type [INTERNAL];12: illegal version value [0] for version type [INTERNAL];13: illegal version value [0] for version type [INTERNAL];14: illegal version value [0] for version type [INTERNAL];15: illegal version value [0] for version type [INTERNAL];16: illegal version value [0] for version type [INTERNAL];17: illegal version value [0] for version type [INTERNAL];18: illegal version value [0] for version type [INTERNAL];19: illegal version value [0] for version type [INTERNAL];20: illegal version value [0] for version type [INTERNAL];21: illegal version value [0] for version type [INTERNAL];22: illegal version value [0] for version type [INTERNAL];23: illegal version value [0] for version type [INTERNAL];24: illegal version value [0] for version type [INTERNAL];25: illegal version value [0] for version type [INTERNAL];26: illegal version value [0] for version type [INTERNAL];27: illegal version value [0] for version type [INTERNAL];"

},

"status": 400

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [November 15, 2022, 12:13am UTC](https://discuss.elastic.co/t/deleting-document-by-query/318570/4 "2022-11-15T00:13:10Z")

</div>

Please format your code/logs/config using the `</>` button, or markdown style back ticks. It helps to make things easy to read which helps us help you 🙂

Why don't you just delete the indices if you are deleting all the documents in them anyway?

---

<div class="post-metadata">

**Author:** ![RuizMagana](https://avatars.discourse-cdn.com/v4/letter/r/898d66/32.png) [@RuizMagana](https://discuss.elastic.co/u/RuizMagana)\
**Post date:** [November 21, 2022, 12:09am UTC](https://discuss.elastic.co/t/deleting-document-by-query/318570/5 "2022-11-21T00:09:00Z")

</div>

I hope, it will work for my deleted ones! The first example I found as the described one was like perfect [https://ejemplius.com/muestras-de-ensayos/contrato-social/](https://ejemplius.com/muestras-de-ensayos/contrato-social/) sample. Unfortunately, I didn't understand at that moment what it was. But when I read twice, it became more clear. And now I hope to get more help!

---

<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:** [December 19, 2022, 12:09am UTC](https://discuss.elastic.co/t/deleting-document-by-query/318570/6 "2022-12-19T00:09:11Z")

</div>

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