Getting error `[template] unknown field [index_patterns]` while creating index template in 7.14.0

Hi Team,

I am creating index template (not legacy template) in kibana in version 7.14.0 but can see below error in 6th step of Review template in preview tab.

{
  "statusCode": 400,
  "error": "Bad Request",
  "message": "[1:414] [index_template] failed to parse field [template]",
  "attributes": {
    "message": "[1:414] [index_template] failed to parse field [template]",
    "cause": [
      "[1:397] [template] unknown field [index_patterns]"
    ]
  }
}

still i used the template created from above and trying to apply it but getting below error.

    "content": "{\"error\":{\"root_cause\":[{\"type\":\"x_content_parse_exception\",\"reason\":\"[1:68] [index_template] unknown field [template] did you mean [template]?\"}],\"type\":\"x_content_parse_exception\",\"reason\":\"[1:68] [index_template] unknown field [template] did you mean [template]?\"},\"status\":400}",
    "content_length": "281",
    "content_type": "application/json; charset=UTF-8",
    "elapsed": 0,
    "json": {
        "error": {
            "reason": "[1:68] [index_template] unknown field [template] did you mean [template]?",
            "root_cause": [
                {
                    "reason": "[1:68] [index_template] unknown field [template] did you mean [template]?",
                    "type": "x_content_parse_exception"
                }
            ],
            "type": "x_content_parse_exception"
        },
        "status": 400
    },
    "redirected": false,
    "status": 400,
    "url": "http://10.10.10.126:9200/_index_template/template"
}

MSG:

Status code was 400 and not [200]: HTTP Error 400: Bad Request

the index template is -

{
  "version": 2,
  "priority": 600,
  "template": {
    "settings": {
      "index.number_of_shards": 1,
      "index.number_of_replicas": 0,
      "index.lifecycle.name": "testpolicy",      
      "index.lifecycle.rollover_alias": "access" 
    },
    "mappings": {
      "_source": {
        "enabled": true,
        "includes": [],
        "excludes": []
      },
      "_routing": {
        "required": false
      },
      "dynamic": true,
      "numeric_detection": true,
      "date_detection": true,
      "dynamic_date_formats": [
        "strict_date_optional_time",
        "yyyy/MM/dd HH:mm:ss Z||yyyy/MM/dd Z"
      ],
      "dynamic_templates": []
    },
    "aliases": {
      "aliases": "access"
    }
  },
  "index_patterns": [
    "access*"
  ]
}

and applying template like below.

- name: creating index template
  uri:
    method: PUT
    url: "http://{{ elasticsearch1_private_ip }}:{{ elasticsearch_port }}/_index_template/template"
    body: "{{ lookup('file', '{{ buildstore }}/template.json') }}"
    body_format: json
    user: "{{ elasticsearch_username }}"
    password: "{{ elasticsearch_password }}"
    status_code: 200

This is the how template is getting created from kibana after selecting desired options but not sure why its giving error when nothing in it is added manually in template file.

Thanks,

Hey @prathamesh7,

It's not clear from the error, but I believe your problem is that aliases under template is formatted incorrectly. It is an object of objects, e.g.

"aliases": {
  "alias_name": {
    "setting": "value"
  }
}

Take a look at aliases on this page: Create or update index template API | Elasticsearch Guide [7.14] | Elastic

Let me know if that helps.

Brian

Hi @brianseeders ,

can i use it like

{
"aliases" : {
"alias1": {
      "aliases" : "access"
}
}
}

Thanks,

I think this is correct as after changing like above ,i cannot see error in preview tab. Thanks.

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