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

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.

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

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!

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.

Yeah got it. Cool.

Thanks for your help for resolving the issue.

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.

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.

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