# Automatic deletion of old documents

**URL:** <https://discuss.elastic.co/t/automatic-deletion-of-old-documents/287297>\
**Category:** Elasticsearch\
**Created:** [October 21, 2021, 9:57am UTC](https://discuss.elastic.co/t/automatic-deletion-of-old-documents/287297 "2021-10-21T09:57:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![x41lakazam](https://avatars.discourse-cdn.com/v4/letter/x/ba8739/32.png) [@x41lakazam](https://discuss.elastic.co/u/x41lakazam)\
**Post date:** [October 21, 2021, 9:57am UTC](https://discuss.elastic.co/t/automatic-deletion-of-old-documents/287297/1 "2021-10-21T09:57:07Z")

</div>

Hi there,

Is there a way to configure an index so that every document gets deleted once he is more than 90 days ?

I saw a lot of topics that propose to use a delete query in a crontab job but that sounds very inefficient.  
Some other propose to add a lifecycle policy that create a shard every day and delete every shard older than 90 days, this sounds good but I'd like to know if there isn't something built in.

Thanks.

---

<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:** [October 21, 2021, 11:31am UTC](https://discuss.elastic.co/t/automatic-deletion-of-old-documents/287297/2 "2021-10-21T11:31:11Z")

</div>

What is your use case? Are you indexing immutable documents or are you performing updates?

---

<div class="post-metadata">

**Author:** ![x41lakazam](https://avatars.discourse-cdn.com/v4/letter/x/ba8739/32.png) [@x41lakazam](https://discuss.elastic.co/u/x41lakazam)\
**Post date:** [October 25, 2021, 8:41am UTC](https://discuss.elastic.co/t/automatic-deletion-of-old-documents/287297/3 "2021-10-25T08:41:35Z")

</div>

I'm pushing immutable documents, I'm not touching them after they were pushed

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [October 25, 2021, 8:57am UTC](https://discuss.elastic.co/t/automatic-deletion-of-old-documents/287297/4 "2021-10-25T08:57:24Z")

</div>

Check out [ILM](https://www.elastic.co/guide/en/elasticsearch/reference/current/index-lifecycle-management.html), which makes the assumption that you are using time based, immutable data.

---

<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:** [November 22, 2021, 8:57am UTC](https://discuss.elastic.co/t/automatic-deletion-of-old-documents/287297/5 "2021-11-22T08:57:52Z")

</div>

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