# How can I delete a document when it is X month old?

**URL:** <https://discuss.elastic.co/t/how-can-i-delete-a-document-when-it-is-x-month-old/364958>\
**Category:** Elasticsearch\
**Created:** [August 15, 2024, 2:08pm UTC](https://discuss.elastic.co/t/how-can-i-delete-a-document-when-it-is-x-month-old/364958 "2024-08-15T14:08:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arkapravo\_Das](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arkapravo_das/32/78953_2.png) [@Arkapravo\_Das](https://discuss.elastic.co/u/Arkapravo_Das)\
**Post date:** [August 15, 2024, 2:08pm UTC](https://discuss.elastic.co/t/how-can-i-delete-a-document-when-it-is-x-month-old/364958/1 "2024-08-15T14:08:52Z")

</div>

I have an index and document gets added to that index everyday ,lets say with a frequency of 10,000 daily. I want to delete the documents which are 5 month old from that index and want to run this deletion process daily once for maintenance purpose.One important point, I can't walk in the route of creating new index and deleting the entire index.

---

<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:** [August 15, 2024, 2:40pm UTC](https://discuss.elastic.co/t/how-can-i-delete-a-document-when-it-is-x-month-old/364958/2 "2024-08-15T14:40:57Z")

</div>

You will need to invoke the [delete by query API](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html) from a script or application outside Elasticsearch.
