# Compress Elasticsearch Index after x days

**URL:** <https://discuss.elastic.co/t/compress-elasticsearch-index-after-x-days/269430>\
**Category:** Elasticsearch\
**Created:** [April 7, 2021, 9:49am UTC](https://discuss.elastic.co/t/compress-elasticsearch-index-after-x-days/269430 "2021-04-07T09:49:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Harsh\_Sharma](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/harsh_sharma/32/32093_2.png) [@Harsh\_Sharma](https://discuss.elastic.co/u/Harsh_Sharma)\
**Post date:** [April 7, 2021, 9:49am UTC](https://discuss.elastic.co/t/compress-elasticsearch-index-after-x-days/269430/1 "2021-04-07T09:49:51Z")

</div>

Hi All,

I'm using ELK version 6.5.8. Using curator retention period of ES index are maintaining i.e. 7 days. Here is a requirement where I want to keep 3 days data in index & data more than 3 days should compress & got delete after 7 days.

using **index.codec: best\_compression** in elasticsearch.yml file will compress all the data of index.

Need help how to compress data that is more than 3 days old.

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:** [April 7, 2021, 1:35pm UTC](https://discuss.elastic.co/t/compress-elasticsearch-index-after-x-days/269430/2 "2021-04-07T13:35:14Z")

</div>

[Index Lifecycle Management feature](https://www.elastic.co/guide/en/elasticsearch/reference/current/index-lifecycle-management.html) is built for that.

---

<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:** [April 7, 2021, 1:36pm UTC](https://discuss.elastic.co/t/compress-elasticsearch-index-after-x-days/269430/3 "2021-04-07T13:36:15Z")

</div>

> [@Harsh\_Sharma](#):
>
> using **index.codec: best\_compression** in elasticsearch.yml file will compress all the data of index.

You can't use that. It's an index level settings that can not be defined in `elasticsearch.yml`.

> [@Harsh\_Sharma](#):
>
> I'm using ELK version 6.5.8.

This is a too old version. You need to upgrade at least to 6.8 or better 7.12.

---

<div class="post-metadata">

**Author:** ![Harsh\_Sharma](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/harsh_sharma/32/32093_2.png) [@Harsh\_Sharma](https://discuss.elastic.co/u/Harsh_Sharma)\
**Post date:** [April 11, 2021, 12:03pm UTC](https://discuss.elastic.co/t/compress-elasticsearch-index-after-x-days/269430/4 "2021-04-11T12:03:51Z")

</div>

Thanks @dadoonet Points are taken. Let me test on upgraded version.

---

<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 29, 2021, 1:04pm UTC](https://discuss.elastic.co/t/compress-elasticsearch-index-after-x-days/269430/6 "2021-05-29T13:04:14Z")

</div>

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