# How to implement deflate (best compression)?

**URL:** https://discuss.elastic.co/t/how-to-implement-deflate-best-compression/289984
**Category:** Elasticsearch
**Created:** [November 23, 2021, 8:13pm UTC](https://discuss.elastic.co/t/how-to-implement-deflate-best-compression/289984 "2021-11-23T20:13:16Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![DineshNaik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dineshnaik/32/89308_2.png) [@DineshNaik](https://discuss.elastic.co/u/DineshNaik)
#### Post date: [November 24, 2021, 11:09am UTC](https://discuss.elastic.co/t/how-to-implement-deflate-best-compression/289984/6 "2021-11-24T11:09:36Z")

</div>

don't you have kibana?

from there you can run the PUT api call directly from Dev tool.

If not then run curl command like :

`curl -XPUT "http://<your cluster ip or fqdn>:9200/_template/my_template" -H 'Content-Type: application/json' -d'{ "index_patterns": ["*"], "settings": { "index": { "codec": "best_compression" } }, "mappings" : { "_source": { "excludes": [] } }}'`

once you run the above command all your new indices will have **best** compression.

If you want to do it for the existing index then you will need to close it first and then change compression setting and then open the index.

something like this:

1. Close all indices:[http://localhost:9200/\_all/\_close](http://localhost:9200/_all/_close)'
2. Apply best\_compression to all curl -XPUT '[http://localhost:9200/\_all/\_settings](http://localhost:9200/_all/_settings)' -d '{"index.codec" : "best\_compression"}'
3. Open all indices: curl -XPOST '[http://localhost:9200/\_all/\_open](http://localhost:9200/_all/_open)'

---

_[View the full topic](https://discuss.elastic.co/t/how-to-implement-deflate-best-compression/289984)._
