# Set \_id field when creating index template

**URL:** https://discuss.elastic.co/t/set-id-field-when-creating-index-template/206706
**Category:** Kibana
**Created:** [November 6, 2019, 2:38am UTC](https://discuss.elastic.co/t/set-id-field-when-creating-index-template/206706 "2019-11-06T02:38:13Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![newkate12](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/newkate12/32/45037_2.png) [@newkate12](https://discuss.elastic.co/u/newkate12)
#### Post date: [November 6, 2019, 2:38am UTC](https://discuss.elastic.co/t/set-id-field-when-creating-index-template/206706/1 "2019-11-06T02:38:14Z")

</div>

I want to use index template when creating index in elasticsearch.  
I saw that we can set \_id field with specific field when creating index.  
([https://www.elastic.co/guide/en/elasticsearch/reference/1.4/mapping-id-field.html](https://www.elastic.co/guide/en/elasticsearch/reference/1.4/mapping-id-field.html))

Is it possible to set \_id field when creating index template like this way?  
For example, suppose that I want to set \_id as "tag\_seq" field when creating index template..

```
PUT _template/template_1
{
  "index_patterns": ["te*", "bar*"],
  "settings": {
    "number_of_shards": 1
  },
  "mappings": {
    "_source": {
      "enabled": false
    },
    "properties": {
      "host_name": {
        "type": "keyword"
      },
      "tag_seq" : {
        "type" : "integer"
      },
      "created_at": {
        "type": "date",
        "format": "EEE MMM dd HH:mm:ss Z yyyy"
      },
      "_id" : {
        "path" : "tag_seq",
        "type" : "integer"
      }
       
    }
  }
}

```

I tried to use the script above, but it gives me an error...

---

<div class="post-metadata">

### Author: ![mattkime](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattkime/32/43522_2.png) [@mattkime](https://discuss.elastic.co/u/mattkime)
#### Post date: [November 11, 2019, 8:50pm UTC](https://discuss.elastic.co/t/set-id-field-when-creating-index-template/206706/2 "2019-11-11T20:50:17Z")

</div>

What version of the elasticsearch stack are you using and what error are you getting?

---

<div class="post-metadata">

### Author: ![newkate12](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/newkate12/32/45037_2.png) [@newkate12](https://discuss.elastic.co/u/newkate12)
#### Post date: [November 18, 2019, 8:27am UTC](https://discuss.elastic.co/t/set-id-field-when-creating-index-template/206706/3 "2019-11-18T08:27:53Z")

</div>

My elasticsearch version is 7.3.2 and  
I've got the error below.

```
{
  "error": {
    "root_cause": [
      {
        "type": "mapper_parsing_exception",
        "reason": "No type specified for field [_id]"
      }
    ],
    "type": "mapper_parsing_exception",
    "reason": "Failed to parse mapping [_doc]: No type specified for field [_id]",
    "caused_by": {
      "type": "mapper_parsing_exception",
      "reason": "No type specified for field [_id]"
    }
  },
  "status": 400
}

```

Without the \_id setting part

```
"_id" : {
        "path" : "tag_seq",
        "type" : "integer"
      }

```

it works fine. Any Ideas?

---

<div class="post-metadata">

### Author: ![mattkime](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattkime/32/43522_2.png) [@mattkime](https://discuss.elastic.co/u/mattkime)
#### Post date: [December 7, 2019, 3:52am UTC](https://discuss.elastic.co/t/set-id-field-when-creating-index-template/206706/4 "2019-12-07T03:52:10Z")

</div>

Sorry I missed your response, did you resolve this?

---

<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: [January 4, 2020, 3:52am UTC](https://discuss.elastic.co/t/set-id-field-when-creating-index-template/206706/5 "2020-01-04T03:52:19Z")

</div>

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