# How to remove data in an index of elastic search that is two week old

**URL:** <https://discuss.elastic.co/t/how-to-remove-data-in-an-index-of-elastic-search-that-is-two-week-old/169675>\
**Category:** Elasticsearch\
**Created:** [February 23, 2019, 5:03pm UTC](https://discuss.elastic.co/t/how-to-remove-data-in-an-index-of-elastic-search-that-is-two-week-old/169675 "2019-02-23T17:03:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![PRUDHVI\_CHOWDHARY\_NE](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@PRUDHVI\_CHOWDHARY\_NE](https://discuss.elastic.co/u/PRUDHVI_CHOWDHARY_NE)\
**Post date:** [February 23, 2019, 5:03pm UTC](https://discuss.elastic.co/t/how-to-remove-data-in-an-index-of-elastic-search-that-is-two-week-old/169675/1 "2019-02-23T17:03:11Z")

</div>

I have an index named "registration" in my elastic search.And i inserted data in that index through kibana.

Now i want to remove data in that index that is two weeks old.how can i do this

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 23, 2019, 5:52pm UTC](https://discuss.elastic.co/t/how-to-remove-data-in-an-index-of-elastic-search-that-is-two-week-old/169675/2 "2019-02-23T17:52:58Z")

</div>

Better to use time based indices and just remove the indices.

Otherwise but much less efficient use the delete by query API.

---

<div class="post-metadata">

**Author:** ![PRUDHVI\_CHOWDHARY\_NE](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@PRUDHVI\_CHOWDHARY\_NE](https://discuss.elastic.co/u/PRUDHVI_CHOWDHARY_NE)\
**Post date:** [February 24, 2019, 4:23am UTC](https://discuss.elastic.co/t/how-to-remove-data-in-an-index-of-elastic-search-that-is-two-week-old/169675/3 "2019-02-24T04:23:50Z")

</div>

i want to delete my log files in an index that are 2 weeks old automatically but not to delete my index.

---

<div class="post-metadata">

**Author:** ![PRUDHVI\_CHOWDHARY\_NE](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@PRUDHVI\_CHOWDHARY\_NE](https://discuss.elastic.co/u/PRUDHVI_CHOWDHARY_NE)\
**Post date:** [February 24, 2019, 4:25am UTC](https://discuss.elastic.co/t/how-to-remove-data-in-an-index-of-elastic-search-that-is-two-week-old/169675/4 "2019-02-24T04:25:41Z")

</div>

how can i do this.

curator deletes whole index(as far i know),but i want to delete all logs(or)documents in an index that are 2 weeks old and this need to be done automatically every time

---

<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:** [February 24, 2019, 7:24am UTC](https://discuss.elastic.co/t/how-to-remove-data-in-an-index-of-elastic-search-that-is-two-week-old/169675/5 "2019-02-24T07:24:13Z")

</div>

As David mentioned you will need to do this by periodically scheduling calls to the delete by query API. This is more expensive than deleting indices and not automated nor supported by Curator.

---

<div class="post-metadata">

**Author:** ![freaka](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/freaka/32/41962_2.png) [@freaka](https://discuss.elastic.co/u/freaka)\
**Post date:** [February 25, 2019, 8:57am UTC](https://discuss.elastic.co/t/how-to-remove-data-in-an-index-of-elastic-search-that-is-two-week-old/169675/6 "2019-02-25T08:57:12Z")

</div>

Generally a log line includes some sort of timestamp. Now I'm not well informed about the issue so maybe that suggestion may seem stupid, but is it possible to delete document based on the content of the log line ?

---

<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:** [March 25, 2019, 8:57am UTC](https://discuss.elastic.co/t/how-to-remove-data-in-an-index-of-elastic-search-that-is-two-week-old/169675/7 "2019-03-25T08:57:17Z")

</div>

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