# Delete all documents from specific ES index, that are not in the logstash feed

**URL:** <https://discuss.elastic.co/t/delete-all-documents-from-specific-es-index-that-are-not-in-the-logstash-feed/241318>\
**Category:** Logstash\
**Created:** [July 15, 2020, 2:50pm UTC](https://discuss.elastic.co/t/delete-all-documents-from-specific-es-index-that-are-not-in-the-logstash-feed/241318 "2020-07-15T14:50:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deleanu\_Alexandru](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/deleanu_alexandru/32/72194_2.png) [@Deleanu\_Alexandru](https://discuss.elastic.co/u/Deleanu_Alexandru)\
**Post date:** [July 15, 2020, 2:50pm UTC](https://discuss.elastic.co/t/delete-all-documents-from-specific-es-index-that-are-not-in-the-logstash-feed/241318/1 "2020-07-15T14:50:09Z")

</div>

Hello,

I am writing an ES ecommerce product search.

I feed data to ES using filebeat and logstash like this:  
- every 24h I will upload a json file containing all the products in the ES index (all products that I want to search)  
- I will have 2 pipelines opened for this:  
- one for UPSERT on uid. This works perfectly.  
- one that should DELETE all documents from ES that are no longer in the json file.  
- every 5 min I will upload a json file with the products that have been modified by the ecommerce platform). This will use the UPSERT pipeline from above.

**Is there a way to do the deletion part from the logstash conf file?**

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [July 15, 2020, 5:21pm UTC](https://discuss.elastic.co/t/delete-all-documents-from-specific-es-index-that-are-not-in-the-logstash-feed/241318/2 "2020-07-15T17:21:44Z")

</div>

I would suggest including a "last updated" field in the upsert, then deleting any documents with an out of date "last updated" field.

---

<div class="post-metadata">

**Author:** ![Deleanu\_Alexandru](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/deleanu_alexandru/32/72194_2.png) [@Deleanu\_Alexandru](https://discuss.elastic.co/u/Deleanu_Alexandru)\
**Post date:** [July 16, 2020, 7:15am UTC](https://discuss.elastic.co/t/delete-all-documents-from-specific-es-index-that-are-not-in-the-logstash-feed/241318/3 "2020-07-16T07:15:48Z")

</div>

Thank you for taking the time to help me with this. The "last update" suggestion is better than what I have right now.

---

<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 13, 2020, 7:15am UTC](https://discuss.elastic.co/t/delete-all-documents-from-specific-es-index-that-are-not-in-the-logstash-feed/241318/4 "2020-08-13T07:15:49Z")

</div>

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