# Apply best\_compression to save disk space

**URL:** <https://discuss.elastic.co/t/apply-best-compression-to-save-disk-space/289705>\
**Category:** Elasticsearch\
**Created:** [November 19, 2021, 3:15pm UTC](https://discuss.elastic.co/t/apply-best-compression-to-save-disk-space/289705 "2021-11-19T15:15:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zaeemmasood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zaeemmasood/32/102383_2.png) [@zaeemmasood](https://discuss.elastic.co/u/zaeemmasood)\
**Post date:** [November 19, 2021, 3:15pm UTC](https://discuss.elastic.co/t/apply-best-compression-to-save-disk-space/289705/1 "2021-11-19T15:15:24Z")

</div>

Hi All,

We are struggling with disk space issues on the Elasticsearch nodes. I came across the best\_compression option and the suggested way is as follows using dev tools:

```auto

1. Close all indices:

POST _all/_close

2. Apply best_compression to all

PUT _all/_settings -d '{"index.codec" : "best_compression"}'

3. Open all indices:

POST _all/_open

```

Please guide if this is the correct way to achieve best compression. We have ELK 7.6.2 stack

---

<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:** [November 19, 2021, 3:41pm UTC](https://discuss.elastic.co/t/apply-best-compression-to-save-disk-space/289705/2 "2021-11-19T15:41:19Z")

</div>

In order for the compression to take effect I believe you need to forcemerge the indices down to fewer segments as only newly created/merged segments will get the improved compression applied.

---

<div class="post-metadata">

**Author:** ![zaeemmasood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zaeemmasood/32/102383_2.png) [@zaeemmasood](https://discuss.elastic.co/u/zaeemmasood)\
**Post date:** [November 19, 2021, 7:27pm UTC](https://discuss.elastic.co/t/apply-best-compression-to-save-disk-space/289705/3 "2021-11-19T19:27:41Z")

</div>

Thanks. So should it now look like:

```auto
1. Close all indices:

POST _all/_close

2. Apply best_compression to all

PUT _all/_settings -d '{"index.codec" : "best_compression"}'

3. Open all indices:

POST _all/_open

4. Force merge all indices

POST /_forcemerge

```

---

<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:** [December 17, 2021, 7:28pm UTC](https://discuss.elastic.co/t/apply-best-compression-to-save-disk-space/289705/4 "2021-12-17T19:28:20Z")

</div>

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