# How to overwrite the default template

**URL:** <https://discuss.elastic.co/t/how-to-overwrite-the-default-template/145694>\
**Category:** Elasticsearch\
**Created:** [August 23, 2018, 10:05am UTC](https://discuss.elastic.co/t/how-to-overwrite-the-default-template/145694 "2018-08-23T10:05:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jing\_Wang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jing_wang/32/34618_2.png) [@Jing\_Wang](https://discuss.elastic.co/u/Jing_Wang)\
**Post date:** [August 23, 2018, 10:05am UTC](https://discuss.elastic.co/t/how-to-overwrite-the-default-template/145694/1 "2018-08-23T10:05:25Z")

</div>

hello everyone  
I have a default template setting using pattern \* and set some dynamic mapping

```
PUT /_template/template_default
{
    "index_patterns" : ["*"],
    "order" : 0,
    "settings": {
        "index": {
            "number_of_shards": "3"
        }
    },
    "mappings" : {
        "doc": {
            "dynamic_templates": [
                {
                    "strings_as_keywords": {
                        "match_mapping_type": "string",
                        "mapping": {
                          "type": "keyword",
                          "norms": false
                        }
                    }
                }
            ]
        }
    }
}

```

now i meet some special requirement that the \_type should be `values`. So I create a new template

```
PUT /_template/zabbix_dbl
{
    "index_patterns" : ["zabbix_dbl-*"],
    "order" : 0,
    "settings": {
        "index": {
            "number_of_shards": "3"
        }
    },
     "mappings" : {
      "values" : {
         "properties" : {
            "itemid" : {
               "type" : "long"
            },
            "clock" : {
               "format" : "epoch_second",
               "type" : "date"
            },
            "value" : {
               "type" : "double"
            }
         }
      }
   },
    "aliases": {
        "zabbix_dbl_get": {}
    }
}

```

when i create new index by `PUT zabbix_dbl-000001` there will be an error

```
{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "Rejecting mapping update to [zabbix_dbl-000001] as the final mapping would have more than 1 type: [values, doc]"
      }
    ],
    "type": "illegal_argument_exception",
    "reason": "Rejecting mapping update to [zabbix_dbl-000001] as the final mapping would have more than 1 type: [values, doc]"
  },
  "status": 400
}

```

it seems both above templates are applied to the index

how could i define a template properly having a different mapping \_type name, please?

---

<div class="post-metadata">

**Author:** ![Ethan-Zhang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ethan-zhang/32/54812_2.png) [@Ethan-Zhang](https://discuss.elastic.co/u/Ethan-Zhang)\
**Post date:** [August 23, 2018, 12:03pm UTC](https://discuss.elastic.co/t/how-to-overwrite-the-default-template/145694/2 "2018-08-23T12:03:53Z")

</div>

same question as [Unable to create index with more that 1 type in 6.x](https://discuss.elastic.co/t/unable-to-create-index-with-more-that-1-type-in-6-x/106089)

from 6.x, you can't create more than 1 type in one index

---

<div class="post-metadata">

**Author:** ![Jing\_Wang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jing_wang/32/34618_2.png) [@Jing\_Wang](https://discuss.elastic.co/u/Jing_Wang)\
**Post date:** [August 24, 2018, 1:20am UTC](https://discuss.elastic.co/t/how-to-overwrite-the-default-template/145694/3 "2018-08-24T01:20:28Z")

</div>

Thanks.  
I already know this. But what I want is not an index with 2 type.

I define a default template using `index_patterns *` with a `dynamic_templates` so that every new string type will be mapped as `keyword`.  
In my common use case, I usually ignore the `_type` parameter and I don't care about the \_type of an index. So in this default template, the `_type` name may not necessarily be `doc`.

But in this specific case, since the zabbix process use the index with a `_type` name `values`. I want to know is there some mechanism in elasticsearch so that I can define a template to ignore the `mapping` part of the default `index_patterns *` template or ignore the whole defaule template.

---

<div class="post-metadata">

**Author:** ![Ethan-Zhang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ethan-zhang/32/54812_2.png) [@Ethan-Zhang](https://discuss.elastic.co/u/Ethan-Zhang)\
**Post date:** [August 24, 2018, 3:19am UTC](https://discuss.elastic.co/t/how-to-overwrite-the-default-template/145694/4 "2018-08-24T03:19:27Z")

</div>

you may use `_doc` as type name in template. `_doc` was the only type of the index now in es 6.x.

---

<div class="post-metadata">

**Author:** ![Jing\_Wang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jing_wang/32/34618_2.png) [@Jing\_Wang](https://discuss.elastic.co/u/Jing_Wang)\
**Post date:** [August 27, 2018, 1:45am UTC](https://discuss.elastic.co/t/how-to-overwrite-the-default-template/145694/5 "2018-08-27T01:45:31Z")

</div>

If I use the `_doc` as the type name, I still can't POST an index with `types` as its type.

```
{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "Rejecting mapping update to [test] as the final mapping would have more than 1 type: [types, _doc]"
      }
    ],
    "type": "illegal_argument_exception",
    "reason": "Rejecting mapping update to [test] as the final mapping would have more than 1 type: [types, _doc]"
  },
  "status": 400
}
```

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [August 27, 2018, 2:50am UTC](https://discuss.elastic.co/t/how-to-overwrite-the-default-template/145694/6 "2018-08-27T02:50:10Z")

</div>

Both need to be `_doc`, you cannot have different values.

---

<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:** [September 24, 2018, 2:50am UTC](https://discuss.elastic.co/t/how-to-overwrite-the-default-template/145694/7 "2018-09-24T02:50:16Z")

</div>

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