# We want to automatically delete some document with different expiration dates

**URL:** <https://discuss.elastic.co/t/we-want-to-automatically-delete-some-document-with-different-expiration-dates/243000>\
**Category:** Elasticsearch\
**Created:** [July 29, 2020, 5:32am UTC](https://discuss.elastic.co/t/we-want-to-automatically-delete-some-document-with-different-expiration-dates/243000 "2020-07-29T05:32:01Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![devin.teki](https://avatars.discourse-cdn.com/v4/letter/d/ed8c4c/32.png) [@devin.teki](https://discuss.elastic.co/u/devin.teki)\
**Post date:** [July 29, 2020, 5:32am UTC](https://discuss.elastic.co/t/we-want-to-automatically-delete-some-document-with-different-expiration-dates/243000/1 "2020-07-29T05:32:01Z")

</div>

How to let elasticsearch5.5.2 automatic delete document by some datetime field.  
The `_ttl` mappings have been removed from 5.x. because effifient problem.  
Is there any other way I can delete expired files automatically？

---

<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:** [July 29, 2020, 5:49am UTC](https://discuss.elastic.co/t/we-want-to-automatically-delete-some-document-with-different-expiration-dates/243000/2 "2020-07-29T05:49:00Z")

</div>

The best option these days is to use time based indices, and then just remove them after the expiration time.

Also you really need to upgrade, 5.X is [EOL](https://www.elastic.co/support/eol) and no longer supported

---

<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:** [July 29, 2020, 6:11am UTC](https://discuss.elastic.co/t/we-want-to-automatically-delete-some-document-with-different-expiration-dates/243000/3 "2020-07-29T06:11:15Z")

</div>

If the TTL does not change over time I would recommend time based indices as it is the most efficient way to delete data from Elasticsearch. If there are updates changing it I believe you will need to find a way to schedule delete by query requests, which is what the TTL functionality did behind the scenes. This suffers from the same performance problems as TTL as it is an expensive way to delete large amounts of data.

---

<div class="post-metadata">

**Author:** ![devin.teki](https://avatars.discourse-cdn.com/v4/letter/d/ed8c4c/32.png) [@devin.teki](https://discuss.elastic.co/u/devin.teki)\
**Post date:** [July 29, 2020, 10:34am UTC](https://discuss.elastic.co/t/we-want-to-automatically-delete-some-document-with-different-expiration-dates/243000/5 "2020-07-29T10:34:02Z")

</div>

I'm a newer for ES.  
So there is no way to automatically delete document, but can delete index automatically.  
And I don't know how to use time-based indices. I need to study it.  
So can you give me some advice?  
thanks very much.

---

<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:** [July 29, 2020, 9:39pm UTC](https://discuss.elastic.co/t/we-want-to-automatically-delete-some-document-with-different-expiration-dates/243000/6 "2020-07-29T21:39:26Z")

</div>

Check out [ILM](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-start.html), it's the best approach.

---

<div class="post-metadata">

**Author:** ![devin.teki](https://avatars.discourse-cdn.com/v4/letter/d/ed8c4c/32.png) [@devin.teki](https://discuss.elastic.co/u/devin.teki)\
**Post date:** [July 30, 2020, 12:36am UTC](https://discuss.elastic.co/t/we-want-to-automatically-delete-some-document-with-different-expiration-dates/243000/7 "2020-07-30T00:36:17Z")

</div>

Thank you for your help.  
It's pity, we must do this job on the ES 5.5.  
This version is not support ILM.  
We have to use time-based indices or delete by query API.  
There seems to be no other choice here.

---

<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:** [July 30, 2020, 12:41am UTC](https://discuss.elastic.co/t/we-want-to-automatically-delete-some-document-with-different-expiration-dates/243000/8 "2020-07-30T00:41:44Z")

</div>

You really need to upgrade, 5.X is no longer supported. The latest version is 7.8!

---

<div class="post-metadata">

**Author:** ![devin.teki](https://avatars.discourse-cdn.com/v4/letter/d/ed8c4c/32.png) [@devin.teki](https://discuss.elastic.co/u/devin.teki)\
**Post date:** [July 30, 2020, 12:54am UTC](https://discuss.elastic.co/t/we-want-to-automatically-delete-some-document-with-different-expiration-dates/243000/9 "2020-07-30T00:54:32Z")

</div>

I want to talk about that with my leader.  
But I think there will be no results, at least there will be no results in the near future.  
We have just accepted these jobs not long ago.

---

<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 27, 2020, 12:54am UTC](https://discuss.elastic.co/t/we-want-to-automatically-delete-some-document-with-different-expiration-dates/243000/10 "2020-08-27T00:54:33Z")

</div>

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