# Best way to remove docs from index

**URL:** <https://discuss.elastic.co/t/best-way-to-remove-docs-from-index/356271>\
**Category:** Elasticsearch\
**Created:** [March 27, 2024, 11:17am UTC](https://discuss.elastic.co/t/best-way-to-remove-docs-from-index/356271 "2024-03-27T11:17:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Khaled\_Saidi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/khaled_saidi/32/98636_2.png) [@Khaled\_Saidi](https://discuss.elastic.co/u/Khaled_Saidi)\
**Post date:** [March 27, 2024, 11:17am UTC](https://discuss.elastic.co/t/best-way-to-remove-docs-from-index/356271/1 "2024-03-27T11:17:45Z")

</div>

Hi everyone,

I want to clean an index and remove some docs related to a specific filter.  
Notice that this index is used by several logstash pipelines...

I have about 5639694 docs to remove, and a total docs count about 7750149.

What is the best smooth way to do this, i mean without interruption of the indexing of other pipelines ?  
I thought about a delete\_by\_query but it's going to take a lot of time i think...

As always, thanks for your help and suggestions.

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [March 27, 2024, 12:59pm UTC](https://discuss.elastic.co/t/best-way-to-remove-docs-from-index/356271/2 "2024-03-27T12:59:50Z")

</div>

> [@Khaled\_Saidi](#):
>
> I thought about a delete\_by\_query but it's going to take a lot of time i think...

To remove existing documents from an index the only way is to use `delete_by_query`, there is no other way.

---

<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:** [April 24, 2024, 1:00pm UTC](https://discuss.elastic.co/t/best-way-to-remove-docs-from-index/356271/3 "2024-04-24T13:00:01Z")

</div>

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