# Index.codec in template is not accepting anymore in ES6.5?

**URL:** <https://discuss.elastic.co/t/index-codec-in-template-is-not-accepting-anymore-in-es6-5/167807>\
**Category:** Elasticsearch\
**Created:** [February 11, 2019, 8:54am UTC](https://discuss.elastic.co/t/index-codec-in-template-is-not-accepting-anymore-in-es6-5/167807 "2019-02-11T08:54:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Suryadip\_Nag](https://avatars.discourse-cdn.com/v4/letter/s/2bfe46/32.png) [@Suryadip\_Nag](https://discuss.elastic.co/u/Suryadip_Nag)\
**Post date:** [February 11, 2019, 8:54am UTC](https://discuss.elastic.co/t/index-codec-in-template-is-not-accepting-anymore-in-es6-5/167807/1 "2019-02-11T08:54:16Z")

</div>

We have migrated to Elasticsearch from 5.5 to 6.5. We have field in template index.codec but it is not accepting anymore when I try to create the template in ES6.5. But same template is getting created in ES5.5.

curl -X PUT "localhost:9200/\_template/junoslogs" -H 'Content-Type: application/json' -d @template-lc.json  
{" **error**":{"root\_cause":[{"type":"parse\_exception","reason":"**unknown key [index.codec**] in the template "}],"type":"parse\_exception","reason":"unknown key [index.codec] in the template "},"status":400}

Template snippet is like below:

{  
"order": 0,  
"template": "jlogs-\*",  
**"index.codec": "best\_compression"** ,  
"settings": {  
"index.refresh\_interval": "5s",  
"index":{  
"number\_of\_shards" : 2,  
"number\_of\_replicas" : 0,  
........

Please help.

---

<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:** [February 11, 2019, 8:55am UTC](https://discuss.elastic.co/t/index-codec-in-template-is-not-accepting-anymore-in-es6-5/167807/2 "2019-02-11T08:55:55Z")

</div>

Try putting the `codec` information inside the `index` block you have specified next to `number_of_shards`.

---

<div class="post-metadata">

**Author:** ![Suryadip\_Nag](https://avatars.discourse-cdn.com/v4/letter/s/2bfe46/32.png) [@Suryadip\_Nag](https://discuss.elastic.co/u/Suryadip_Nag)\
**Post date:** [February 11, 2019, 9:14am UTC](https://discuss.elastic.co/t/index-codec-in-template-is-not-accepting-anymore-in-es6-5/167807/3 "2019-02-11T09:14:22Z")

</div>

Thanks buddy. Yes, it has worked if we put like below.

"settings" : {  
"index" : {  
"codec" : "best\_compression"

But in 5.5 it was accepting outside the index block. Strange!

---

<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:** [February 11, 2019, 9:17am UTC](https://discuss.elastic.co/t/index-codec-in-template-is-not-accepting-anymore-in-es6-5/167807/4 "2019-02-11T09:17:11Z")

</div>

Elasticsearch has been improving validations so it is possible this is a side effect of that. The dot notation would probably work if you did not already have the index block present.

---

<div class="post-metadata">

**Author:** ![Suryadip\_Nag](https://avatars.discourse-cdn.com/v4/letter/s/2bfe46/32.png) [@Suryadip\_Nag](https://discuss.elastic.co/u/Suryadip_Nag)\
**Post date:** [February 11, 2019, 9:19am UTC](https://discuss.elastic.co/t/index-codec-in-template-is-not-accepting-anymore-in-es6-5/167807/5 "2019-02-11T09:19:58Z")

</div>

Yeah got it. Cool.

Thanks for your help for resolving the issue.

---

<div class="post-metadata">

**Author:** ![Suryadip\_Nag](https://avatars.discourse-cdn.com/v4/letter/s/2bfe46/32.png) [@Suryadip\_Nag](https://discuss.elastic.co/u/Suryadip_Nag)\
**Post date:** [February 11, 2019, 10:34am UTC](https://discuss.elastic.co/t/index-codec-in-template-is-not-accepting-anymore-in-es6-5/167807/6 "2019-02-11T10:34:23Z")

</div>

Hi Christian,

I just wanted to update you as this info might be useful for Elasticsearch team.

As I mentioned that codec tag worked if I move it to under index. But it is also working if we put index.codec outside the index tag but inside the settings tag. Like below.

{  
"order": 0,  
"template": "junoslogs-\*",  
" **settings**": {  
"index.refresh\_interval": "5s",  
" **index.codec**": "best\_compression",  
"index":{  
"number\_of\_shards" : 2,  
"number\_of\_replicas" : 0,

But yeah, outside the settings it is not working like I faced the issue as reported.

---

<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:** [February 11, 2019, 10:37am UTC](https://discuss.elastic.co/t/index-codec-in-template-is-not-accepting-anymore-in-es6-5/167807/7 "2019-02-11T10:37:56Z")

</div>

Aha. It has to be under settings and I did not notice this was the case in the initial post as it was not indented properly.

---

<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:** [March 11, 2019, 10:38am UTC](https://discuss.elastic.co/t/index-codec-in-template-is-not-accepting-anymore-in-es6-5/167807/8 "2019-03-11T10:38:06Z")

</div>

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