# Getting error \`\[template\] unknown field \[index\_patterns\]\` while creating index template in 7.14.0

**URL:** https://discuss.elastic.co/t/getting-error-template-unknown-field-index-patterns-while-creating-index-template-in-7-14-0/283700
**Category:** Kibana
**Created:** [September 8, 2021, 6:21pm UTC](https://discuss.elastic.co/t/getting-error-template-unknown-field-index-patterns-while-creating-index-template-in-7-14-0/283700 "2021-09-08T18:21:17Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![prathamesh7](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prathamesh7/32/99920_2.png) [@prathamesh7](https://discuss.elastic.co/u/prathamesh7)
#### Post date: [September 8, 2021, 6:21pm UTC](https://discuss.elastic.co/t/getting-error-template-unknown-field-index-patterns-while-creating-index-template-in-7-14-0/283700/1 "2021-09-08T18:21:17Z")

</div>

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.

```auto
{
  "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.

```auto
    "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 -

```auto
{
  "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.

```auto
- 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,

---

<div class="post-metadata">

### Author: ![brianseeders](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brianseeders/32/84831_2.png) [@brianseeders](https://discuss.elastic.co/u/brianseeders)
#### Post date: [September 8, 2021, 7:04pm UTC](https://discuss.elastic.co/t/getting-error-template-unknown-field-index-patterns-while-creating-index-template-in-7-14-0/283700/2 "2021-09-08T19:04:05Z")

</div>

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.

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

```

Take a look at `aliases` on this page: [Create or update index template API | Elasticsearch Guide [7.14] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-template.html)

Let me know if that helps.

Brian

---

<div class="post-metadata">

### Author: ![prathamesh7](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prathamesh7/32/99920_2.png) [@prathamesh7](https://discuss.elastic.co/u/prathamesh7)
#### Post date: [September 8, 2021, 7:17pm UTC](https://discuss.elastic.co/t/getting-error-template-unknown-field-index-patterns-while-creating-index-template-in-7-14-0/283700/3 "2021-09-08T19:17:42Z")

</div>

Hi @brianseeders ,

can i use it like

```auto
{
"aliases" : {
"alias1": {
      "aliases" : "access"
}
}
}

```

Thanks,

---

<div class="post-metadata">

### Author: ![prathamesh7](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prathamesh7/32/99920_2.png) [@prathamesh7](https://discuss.elastic.co/u/prathamesh7)
#### Post date: [September 8, 2021, 7:25pm UTC](https://discuss.elastic.co/t/getting-error-template-unknown-field-index-patterns-while-creating-index-template-in-7-14-0/283700/4 "2021-09-08T19:25:58Z")

</div>

I think this is correct as after changing like above ,i cannot see error in preview tab. 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: [October 6, 2021, 7:26pm UTC](https://discuss.elastic.co/t/getting-error-template-unknown-field-index-patterns-while-creating-index-template-in-7-14-0/283700/5 "2021-10-06T19:26:31Z")

</div>

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