# How to set \`index.codec: best\_compression\` as the default for all future indices?

**URL:** <https://discuss.elastic.co/t/how-to-set-index-codec-best-compression-as-the-default-for-all-future-indices/335383>\
**Category:** Elasticsearch\
**Created:** [June 6, 2023, 11:57pm UTC](https://discuss.elastic.co/t/how-to-set-index-codec-best-compression-as-the-default-for-all-future-indices/335383 "2023-06-06T23:57:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jerrac](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jerrac/32/52980_2.png) [@jerrac](https://discuss.elastic.co/u/jerrac)\
**Post date:** [June 6, 2023, 11:57pm UTC](https://discuss.elastic.co/t/how-to-set-index-codec-best-compression-as-the-default-for-all-future-indices/335383/1 "2023-06-06T23:57:19Z")

</div>

Pretty much what the subject says. How to I turn on best\_compression as the default for all new indices?

[The docs](https://www.elastic.co/guide/en/elasticsearch/reference/8.7/index-modules.html#index-codec) explain how to do it per index. But I haven't found anything on setting it as the default.

Nor has google been much help. Just a mention of a deprecated elasticsearch.yml option from 5.x era...

Thanks in advance!

---

<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:** [June 7, 2023, 3:49am UTC](https://discuss.elastic.co/t/how-to-set-index-codec-best-compression-as-the-default-for-all-future-indices/335383/2 "2023-06-07T03:49:46Z")

</div>

You need to set it in an index template.

---

<div class="post-metadata">

**Author:** ![jerrac](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jerrac/32/52980_2.png) [@jerrac](https://discuss.elastic.co/u/jerrac)\
**Post date:** [June 7, 2023, 3:22pm UTC](https://discuss.elastic.co/t/how-to-set-index-codec-best-compression-as-the-default-for-all-future-indices/335383/3 "2023-06-07T15:22:32Z")

</div>

Except all my index templates are managed by Elastic Agent. :\ Hmm... Maybe I can do something to the agent config? I'll look into that idea...

---

<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 5, 2023, 3:22pm UTC](https://discuss.elastic.co/t/how-to-set-index-codec-best-compression-as-the-default-for-all-future-indices/335383/4 "2023-07-05T15:22:46Z")

</div>

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