# How to delete huge number of documents from Index? What can be better option?

**URL:** <https://discuss.elastic.co/t/how-to-delete-huge-number-of-documents-from-index-what-can-be-better-option/350469>\
**Category:** Elasticsearch\
**Created:** [January 5, 2024, 2:31pm UTC](https://discuss.elastic.co/t/how-to-delete-huge-number-of-documents-from-index-what-can-be-better-option/350469 "2024-01-05T14:31:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![msabnis79](https://avatars.discourse-cdn.com/v4/letter/m/8c91f0/32.png) [@msabnis79](https://discuss.elastic.co/u/msabnis79)\
**Post date:** [January 5, 2024, 2:31pm UTC](https://discuss.elastic.co/t/how-to-delete-huge-number-of-documents-from-index-what-can-be-better-option/350469/1 "2024-01-05T14:31:48Z")

</div>

For example, we are having 2 billion documents in an index in ES and want to delete 1 billion documents based on some data from Oracle database?

So i have to copy data from Oracle 1 billion records and based on Primary Key value of Oracle - same present as Column in Index on ES, want to delete those records?

Please suggest any better option.

I can think of below options but not sure

Option1 - Delete 1000 documents by passing in Loops - but this will take huge time

Option2 - add all these documents 1 billion from Oracle to ES index with some new column as DELETE = YES. Based on this column DELETE = YES , take PK value and search the same in ES index - which in turn gets 2 billion records for Deletion. Delete the same.. This is just idea - but not sure how to achieve this?

Thanks in advance.

---

<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:** [February 2, 2024, 2:32pm UTC](https://discuss.elastic.co/t/how-to-delete-huge-number-of-documents-from-index-what-can-be-better-option/350469/2 "2024-02-02T14:32:10Z")

</div>

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