How to delete multiple documents using field values?

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

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

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

1 Like

You will hit the limitation.

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 setting.

1 Like

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