# Deleting documents from index

**URL:** <https://discuss.elastic.co/t/deleting-documents-from-index/234511>\
**Category:** Elasticsearch\
**Created:** [May 27, 2020, 9:57am UTC](https://discuss.elastic.co/t/deleting-documents-from-index/234511 "2020-05-27T09:57:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![reddy1262](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/reddy1262/32/68722_2.png) [@reddy1262](https://discuss.elastic.co/u/reddy1262)\
**Post date:** [May 27, 2020, 9:57am UTC](https://discuss.elastic.co/t/deleting-documents-from-index/234511/1 "2020-05-27T09:57:22Z")

</div>

Hi Team,

we want to delete documents which are older than 30 days for an index from Kibana. Please suggest us how can we do this better. We tried below

POST elastalert\_status\_status/\_delete\_by\_query  
{  
"query": {  
"range" : {  
"@timestamp" : {  
"lte" : “now-30d”,  
"format": "MM/dd/yyyy||yyyy"  
}  
}  
}  
}

Deleting documents only flags these as deleted, so they would not be searched. To reclaim disk space we are running below

POST /ielastalert\_status\_status/\_forcemerge?only\_expunge\_deletes=true

Is there any way that we can schedule to run in Kibana or do we need to manually run them everytime?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [May 27, 2020, 12:32pm UTC](https://discuss.elastic.co/t/deleting-documents-from-index/234511/2 "2020-05-27T12:32:28Z")

</div>

The most efficient way to she data out of Elasticsearch is to use time-based indices and just delete complete indices once all data the hold is older than the retention period. For tv joe there is support in Kibana through ILM. As far as I know there is no way to periodically run delete by query from Kibana so you may need to schedule a task through corn or similar.

---

<div class="post-metadata">

**Author:** ![reddy1262](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/reddy1262/32/68722_2.png) [@reddy1262](https://discuss.elastic.co/u/reddy1262)\
**Post date:** [May 28, 2020, 11:07am UTC](https://discuss.elastic.co/t/deleting-documents-from-index/234511/3 "2020-05-28T11:07:29Z")

</div>

thanks Chris

---

<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:** [June 25, 2020, 11:07am UTC](https://discuss.elastic.co/t/deleting-documents-from-index/234511/4 "2020-06-25T11:07:37Z")

</div>

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