# How to delete the docs which are older than 5 hours from an index using curator and the index must remain

**URL:** <https://discuss.elastic.co/t/how-to-delete-the-docs-which-are-older-than-5-hours-from-an-index-using-curator-and-the-index-must-remain/228120>\
**Category:** Elasticsearch\
**Tags:** curator\
**Created:** [April 15, 2020, 12:34pm UTC](https://discuss.elastic.co/t/how-to-delete-the-docs-which-are-older-than-5-hours-from-an-index-using-curator-and-the-index-must-remain/228120 "2020-04-15T12:34:36Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dragon9](https://avatars.discourse-cdn.com/v4/letter/d/7bcc69/32.png) [@Dragon9](https://discuss.elastic.co/u/Dragon9)\
**Post date:** [April 15, 2020, 12:34pm UTC](https://discuss.elastic.co/t/how-to-delete-the-docs-which-are-older-than-5-hours-from-an-index-using-curator-and-the-index-must-remain/228120/1 "2020-04-15T12:34:37Z")

</div>

i want remaining docs should be stay rather than old docs in a 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:** [April 15, 2020, 12:43pm UTC](https://discuss.elastic.co/t/how-to-delete-the-docs-which-are-older-than-5-hours-from-an-index-using-curator-and-the-index-must-remain/228120/2 "2020-04-15T12:43:09Z")

</div>

Curator deletes complete indices, not documents within an index so it may not be suitable here. What is the use case? Why delete documents that are only 5 hours old?

---

<div class="post-metadata">

**Author:** ![Dragon9](https://avatars.discourse-cdn.com/v4/letter/d/7bcc69/32.png) [@Dragon9](https://discuss.elastic.co/u/Dragon9)\
**Post date:** [April 15, 2020, 1:02pm UTC](https://discuss.elastic.co/t/how-to-delete-the-docs-which-are-older-than-5-hours-from-an-index-using-curator-and-the-index-must-remain/228120/3 "2020-04-15T13:02:45Z")

</div>

my usecase is to delete indices older than 44 hours  
so i create hourly indexes in logstash but it cause shards failed because of multiple indices so i want solution to create index in every 5 hours so the number of indexes is minimum.

I want alternative from you for this use case

---

<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:** [April 15, 2020, 1:15pm UTC](https://discuss.elastic.co/t/how-to-delete-the-docs-which-are-older-than-5-hours-from-an-index-using-curator-and-the-index-must-remain/228120/4 "2020-04-15T13:15:37Z")

</div>

I would recommend looking into the rollover api.

---

<div class="post-metadata">

**Author:** ![Dragon9](https://avatars.discourse-cdn.com/v4/letter/d/7bcc69/32.png) [@Dragon9](https://discuss.elastic.co/u/Dragon9)\
**Post date:** [April 15, 2020, 1:21pm UTC](https://discuss.elastic.co/t/how-to-delete-the-docs-which-are-older-than-5-hours-from-an-index-using-curator-and-the-index-must-remain/228120/5 "2020-04-15T13:21:19Z")

</div>

but i have 100 of indices than how to do that manaully for each

---

<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:** [April 15, 2020, 1:31pm UTC](https://discuss.elastic.co/t/how-to-delete-the-docs-which-are-older-than-5-hours-from-an-index-using-curator-and-the-index-must-remain/228120/6 "2020-04-15T13:31:35Z")

</div>

You can use rollover with Curator or ILM. If that is not an option due to the number of indices I suspect you will need to create some kind of custom automated process or simply reduce the number of indices until it is more manageable.

---

<div class="post-metadata">

**Author:** ![Dragon9](https://avatars.discourse-cdn.com/v4/letter/d/7bcc69/32.png) [@Dragon9](https://discuss.elastic.co/u/Dragon9)\
**Post date:** [April 15, 2020, 1:56pm UTC](https://discuss.elastic.co/t/how-to-delete-the-docs-which-are-older-than-5-hours-from-an-index-using-curator-and-the-index-must-remain/228120/7 "2020-04-15T13:56:16Z")

</div>

@Christian_Dahlqvist  
how to do that please help

---

<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:** [April 15, 2020, 1:58pm UTC](https://discuss.elastic.co/t/how-to-delete-the-docs-which-are-older-than-5-hours-from-an-index-using-curator-and-the-index-must-remain/228120/8 "2020-04-15T13:58:38Z")

</div>

I do not know your use case, data or indexing strategy so I am afraid that is something you will need to come up with yourself.

---

<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 13, 2020, 1:58pm UTC](https://discuss.elastic.co/t/how-to-delete-the-docs-which-are-older-than-5-hours-from-an-index-using-curator-and-the-index-must-remain/228120/9 "2020-05-13T13:58:44Z")

</div>

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