# Automatically delete 1 month old documents(without deleting index) in elastic search

**URL:** <https://discuss.elastic.co/t/automatically-delete-1-month-old-documents-without-deleting-index-in-elastic-search/159844>\
**Category:** Elasticsearch\
**Created:** [December 7, 2018, 5:24am UTC](https://discuss.elastic.co/t/automatically-delete-1-month-old-documents-without-deleting-index-in-elastic-search/159844 "2018-12-07T05:24:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sid\_nikhil](https://avatars.discourse-cdn.com/v4/letter/s/f9ae1b/32.png) [@sid\_nikhil](https://discuss.elastic.co/u/sid_nikhil)\
**Post date:** [December 7, 2018, 5:24am UTC](https://discuss.elastic.co/t/automatically-delete-1-month-old-documents-without-deleting-index-in-elastic-search/159844/1 "2018-12-07T05:24:23Z")

</div>

I am new to Elastic Search & I need to delete documents older than 1 month (in all indices) in the elastic search .  
I know how to delete a single document by id / deleting an index , but not able to figure out how to automatically delete 1 month old data in elastic search  
Can somebody please tell how to do that .  
Thanks

---

<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:** [December 7, 2018, 6:31am UTC](https://discuss.elastic.co/t/automatically-delete-1-month-old-documents-without-deleting-index-in-elastic-search/159844/2 "2018-12-07T06:31:18Z")

</div>

You should use time based indices and just drop the old indices using curator project.

Otherwise have a look at the delete by query API.

---

<div class="post-metadata">

**Author:** ![sid\_nikhil](https://avatars.discourse-cdn.com/v4/letter/s/f9ae1b/32.png) [@sid\_nikhil](https://discuss.elastic.co/u/sid_nikhil)\
**Post date:** [December 7, 2018, 6:49am UTC](https://discuss.elastic.co/t/automatically-delete-1-month-old-documents-without-deleting-index-in-elastic-search/159844/3 "2018-12-07T06:49:29Z")

</div>

When i try to create time based index for filebeats,it says "unable to fetch mapping , do you have indices matching that pattern". However the normal index is getting created when i type in filebeat-\*.  
Can u please tell what's wrong here!

 ![Capture](https://us1.discourse-cdn.com/elastic/original/3X/b/2/b2c9af3de8424fdd5971e5e5d9cfd58713a6f5b3.png)

Also can you please provide steps /example of using curator. I am very new to Elastic search.  
Thanks

---

<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:** [December 7, 2018, 2:16pm UTC](https://discuss.elastic.co/t/automatically-delete-1-month-old-documents-without-deleting-index-in-elastic-search/159844/4 "2018-12-07T14:16:06Z")

</div>

For the 1st question, I don't know. May be ask in #kibana for help.  
Check that indices exist:

```
GET _cat/indices?v 

```

Will give the list of existing indices.

For the 2nd question, please read the documentation : [https://www.elastic.co/guide/en/elasticsearch/client/curator/current/index.html](https://www.elastic.co/guide/en/elasticsearch/client/curator/current/index.html)

---

<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:** [January 4, 2019, 2:16pm UTC](https://discuss.elastic.co/t/automatically-delete-1-month-old-documents-without-deleting-index-in-elastic-search/159844/5 "2019-01-04T14:16:16Z")

</div>

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