# Deleting old records from ES

**URL:** <https://discuss.elastic.co/t/deleting-old-records-from-es/17260>\
**Category:** Elasticsearch\
**Created:** [April 29, 2014, 1:04pm UTC](https://discuss.elastic.co/t/deleting-old-records-from-es/17260 "2014-04-29T13:04:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abrar\_Sheikh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abrar_sheikh/32/46187_2.png) [@Abrar\_Sheikh](https://discuss.elastic.co/u/Abrar_Sheikh)\
**Post date:** [April 29, 2014, 1:04pm UTC](https://discuss.elastic.co/t/deleting-old-records-from-es/17260/1 "2014-04-29T13:04:06Z")

</div>

Hi,

I would what to know how to rotate old records from ES index, coz when i  
delete documents with delete query API it does not free up disk space. Eg.  
i want to remove records older than 3 days in my index. For me disk space  
is an issue.

Thanks and Regards,  
Abrar.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/61d35912-72ad-4139-aec3-46fc89f36ac9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/61d35912-72ad-4139-aec3-46fc89f36ac9%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![radu\_gheorghe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/radu_gheorghe/32/556_2.png) [@radu\_gheorghe](https://discuss.elastic.co/u/radu_gheorghe)\
**Post date:** [April 29, 2014, 1:35pm UTC](https://discuss.elastic.co/t/deleting-old-records-from-es/17260/2 "2014-04-29T13:35:45Z")

</div>

Hi Abrar,

When you run delete by query, documents aren't immediately deleted. They  
are marked as deleted and the data gets removed in the process of merging,  
which runs asynchronously in the background. There are some settings that  
make merging more "sensitive" to deletes, have a look here:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

Alternatively, you can force a merge by running optimize:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

But this is also problematic because it will thrash your I/O and invalidate  
much of your caches.

Usually, a better option if you have expiring data is to have time-based  
indices (an index per day, for example). You can then use something like  
the Elasticsearch Curator to expire entire indices as the days go by:

> **[GitHub - elastic/curator: Curator: Tending your Elasticsearch indices](https://github.com/elastic/curator)**
>
> Curator: Tending your Elasticsearch indices. Contribute to elastic/curator development by creating an account on GitHub.

Here's a nice blog post about it:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

Using time-based indices is typically better because removing entire  
indices is super-fast (really remove the associated files and little  
metadata) and doesn't mess up with the rest of your data and caches.

Best regards,  
Radu

--  
Performance Monitoring \* Log Analytics \* Search Analytics  
Solr & Elasticsearch Support \* [http://sematext.com/](http://sematext.com/)

On Tue, Apr 29, 2014 at 4:04 PM, Abrar Sheikh [abrar2002as@gmail.com](mailto:abrar2002as@gmail.com) wrote:

> Hi,
> 
> I would what to know how to rotate old records from ES index, coz when i  
> delete documents with delete query API it does not free up disk space. Eg.  
> i want to remove records older than 3 days in my index. For me disk space  
> is an issue.
> 
> Thanks and Regards,  
> Abrar.
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/61d35912-72ad-4139-aec3-46fc89f36ac9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/61d35912-72ad-4139-aec3-46fc89f36ac9%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/61d35912-72ad-4139-aec3-46fc89f36ac9%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/61d35912-72ad-4139-aec3-46fc89f36ac9%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAHXA0\_3VZzmoJ5J8GSh88J%2BXN%2BOGyPh-bwg7W5r6QokKOMsdoQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAHXA0_3VZzmoJ5J8GSh88J%2BXN%2BOGyPh-bwg7W5r6QokKOMsdoQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [July 6, 2017, 1:32am UTC](https://discuss.elastic.co/t/deleting-old-records-from-es/17260/3 "2017-07-06T01:32:44Z")

</div>


