# Changing codec for existing indexes

**URL:** <https://discuss.elastic.co/t/changing-codec-for-existing-indexes/152422>\
**Category:** Elasticsearch\
**Created:** [October 15, 2018, 5:33am UTC](https://discuss.elastic.co/t/changing-codec-for-existing-indexes/152422 "2018-10-15T05:33:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Neha\_Sharma1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/neha_sharma1/32/36504_2.png) [@Neha\_Sharma1](https://discuss.elastic.co/u/Neha_Sharma1)\
**Post date:** [October 15, 2018, 5:33am UTC](https://discuss.elastic.co/t/changing-codec-for-existing-indexes/152422/1 "2018-10-15T05:33:35Z")

</div>

We are upgrading our ES version to 6.4.2 and would set default compression to best\_comrpession. Problem is that when restoring index from a snapshot, the best-compression is not applied even when explicitly setting codec for that index.

How can I compress my existing index?

---

<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:** [October 15, 2018, 5:44am UTC](https://discuss.elastic.co/t/changing-codec-for-existing-indexes/152422/2 "2018-10-15T05:44:45Z")

</div>

Set the codec to `best_compression` for the index and the run a [force merge down to a single segment](https://www.elastic.co/guide/en/elasticsearch/reference/6.4/indices-forcemerge.html). This will apply the new codec.

---

<div class="post-metadata">

**Author:** ![Neha\_Sharma1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/neha_sharma1/32/36504_2.png) [@Neha\_Sharma1](https://discuss.elastic.co/u/Neha_Sharma1)\
**Post date:** [October 18, 2018, 6:11am UTC](https://discuss.elastic.co/t/changing-codec-for-existing-indexes/152422/3 "2018-10-18T06:11:39Z")

</div>

Thanks!

---

<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:** [November 15, 2018, 6:11am UTC](https://discuss.elastic.co/t/changing-codec-for-existing-indexes/152422/4 "2018-11-15T06:11:43Z")

</div>

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