# Logstash to delete documents in a particular index each time it is run

**URL:** <https://discuss.elastic.co/t/logstash-to-delete-documents-in-a-particular-index-each-time-it-is-run/127264>\
**Category:** Logstash\
**Created:** [April 9, 2018, 7:30am UTC](https://discuss.elastic.co/t/logstash-to-delete-documents-in-a-particular-index-each-time-it-is-run/127264 "2018-04-09T07:30:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ongun](https://avatars.discourse-cdn.com/v4/letter/o/b19c9b/32.png) [@Ongun](https://discuss.elastic.co/u/Ongun)\
**Post date:** [April 9, 2018, 7:30am UTC](https://discuss.elastic.co/t/logstash-to-delete-documents-in-a-particular-index-each-time-it-is-run/127264/1 "2018-04-09T07:30:46Z")

</div>

Hello,

Is it possible in Logstash 6.2.2 to delete all the documents in an index when a pipeline is executed? I need this as SQL queries sent via JDBC interface returns data in the following format: Top 5 largest tables and their names (Table 1, Size 1; Table2, Size 2 etc.) . Obviously this changes as transactions are made to the database. In particular, I noticed that when I delete a table (it is no longer in top 5 largest tables after this obviously) its name and size is still displayed in Kibana and Elasticsearch as I overwrite with respect to table name.

I think of deleting all the documents associated with that index, but do not know how to do that through Logstash. Could you provide help in this matter?

---

<div class="post-metadata">

**Author:** ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)\
**Post date:** [April 13, 2018, 12:58pm UTC](https://discuss.elastic.co/t/logstash-to-delete-documents-in-a-particular-index-each-time-it-is-run/127264/2 "2018-04-13T12:58:14Z")

</div>

I do not know that Logstash can be made to do that. You'd be perhaps better suited to using the Rollover API to just create a new index each time, but keep the same alias, than to do a huge number of atomic delete operations.

---

<div class="post-metadata">

**Author:** ![Ongun](https://avatars.discourse-cdn.com/v4/letter/o/b19c9b/32.png) [@Ongun](https://discuss.elastic.co/u/Ongun)\
**Post date:** [April 18, 2018, 7:07pm UTC](https://discuss.elastic.co/t/logstash-to-delete-documents-in-a-particular-index-each-time-it-is-run/127264/3 "2018-04-18T19:07:01Z")

</div>

Do you mean the this [API](https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-rollover-index.html)?

---

<div class="post-metadata">

**Author:** ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)\
**Post date:** [April 18, 2018, 9:10pm UTC](https://discuss.elastic.co/t/logstash-to-delete-documents-in-a-particular-index-each-time-it-is-run/127264/4 "2018-04-18T21:10:55Z")

</div>

Yes. You can make use of [Elasticsearch Curator](https://www.elastic.co/guide/en/elasticsearch/client/curator/5.5/index.html) to automate this.

---

<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:** [May 16, 2018, 9:20pm UTC](https://discuss.elastic.co/t/logstash-to-delete-documents-in-a-particular-index-each-time-it-is-run/127264/5 "2018-05-16T21:20:15Z")

</div>

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