# How to delete multiple documents using field values?

**URL:** <https://discuss.elastic.co/t/how-to-delete-multiple-documents-using-field-values/191695>\
**Category:** Elasticsearch\
**Created:** [July 22, 2019, 6:07pm UTC](https://discuss.elastic.co/t/how-to-delete-multiple-documents-using-field-values/191695 "2019-07-22T18:07:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![praveengadugin1](https://avatars.discourse-cdn.com/v4/letter/p/858c86/32.png) [@praveengadugin1](https://discuss.elastic.co/u/praveengadugin1)\
**Post date:** [July 22, 2019, 6:07pm UTC](https://discuss.elastic.co/t/how-to-delete-multiple-documents-using-field-values/191695/1 "2019-07-22T18:07:05Z")

</div>

I have a list of 100000 \_ids that have to be deleted from the index. How to delete all of them at once?  
I tried using Delete\_by\_query. But match or multimatch do not take array as input to pass a list of ids . It takes only one \_id at a time. Please help

---

<div class="post-metadata">

**Author:** ![gabriel\_tessier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gabriel_tessier/32/27911_2.png) [@gabriel\_tessier](https://discuss.elastic.co/u/gabriel_tessier)\
**Post date:** [July 23, 2019, 4:03am UTC](https://discuss.elastic.co/t/how-to-delete-multiple-documents-using-field-values/191695/2 "2019-07-23T04:03:46Z")

</div>

Hi @praveengadugin1

You can use Delete\_by\_query with a terms query that accept a list of index, but as I remember there's a limitation in the size of the list.... or maybe there's no limitation. Anyway it not change a lot you can run in several time, slice your 100K ids.

[https://www.elastic.co/guide/en/elasticsearch/reference/7.2/query-dsl-terms-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/7.2/query-dsl-terms-query.html)

Another solution which can be better depends on your data is using "\_reindex" to reindex only the data you need in a fresh new idex. As you need to be aware about side effect if you delete document.

Here a great resource about how lucene handle deleted document:  
[https://www.elastic.co/blog/lucenes-handling-of-deleted-documents](https://www.elastic.co/blog/lucenes-handling-of-deleted-documents)

---

<div class="post-metadata">

**Author:** ![bry-c](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bry-c/32/49123_2.png) [@bry-c](https://discuss.elastic.co/u/bry-c)\
**Post date:** [July 23, 2019, 4:08am UTC](https://discuss.elastic.co/t/how-to-delete-multiple-documents-using-field-values/191695/3 "2019-07-23T04:08:49Z")

</div>

You will hit the limitation.

> [@praveengadugin1](#):
>
> 100000 \_ids that have to be deleted from the index.

> By default, Elasticsearch limits the `terms` query to a maximum of 65,536 terms. You can change this limit using the [`index.max_terms_count`](https://www.elastic.co/guide/en/elasticsearch/reference/7.2/index-modules.html#index-max-terms-count) setting.

---

<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:** [August 20, 2019, 4:08am UTC](https://discuss.elastic.co/t/how-to-delete-multiple-documents-using-field-values/191695/4 "2019-08-20T04:08:49Z")

</div>

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