# Dynamic mapper not working with default mapping

**URL:** <https://discuss.elastic.co/t/dynamic-mapper-not-working-with-default-mapping/89845>\
**Category:** Elasticsearch\
**Created:** [June 18, 2017, 11:57am UTC](https://discuss.elastic.co/t/dynamic-mapper-not-working-with-default-mapping/89845 "2017-06-18T11:57:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vakhtang](https://avatars.discourse-cdn.com/v4/letter/v/3bc359/32.png) [@vakhtang](https://discuss.elastic.co/u/vakhtang)\
**Post date:** [June 18, 2017, 11:57am UTC](https://discuss.elastic.co/t/dynamic-mapper-not-working-with-default-mapping/89845/1 "2017-06-18T11:57:12Z")

</div>

Hello,  
I try to develop solution for use case, when client can create new index only if this index have template.  
As one of possible solutions, i inserted 2 templates:

```
PUT _template/template_all
{
  "template": "*",
  "order":0,
  "settings": {
    "index.mapper.dynamic": false 
  }
}

```

And

```
PUT _template/template_1
{
  "template": "test*",
  "settings": {
    "index.mapper.dynamic": true
  },
  "mappings": {
    "_default_": {
      "_all": {
        "enabled": false
      },
      "dynamic_templates": [
        {
          "strings": {
            "match_mapping_type": "string",
            "mapping": {
              "type": "text",
              "fields": {
                "raw": {
                  "type": "keyword",
                  "ignore_above": 256
                }
              }
            }
          }
        }
      ]
    }
  }
}

```

If i understand right, now all indexes that started with "test" supposed to be creates with ALL document types.  
But as result i received exception "trying to auto create mapping, but dynamic mapping is disabled"  
There is no exceptions if i insert the template with defined document type.

So is this correct, that dynamic mapper not working with default mapping?  
Anybody know other solution for my use case?

Thank a lot

---

<div class="post-metadata">

**Author:** ![thiago](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thiago/32/32096_2.png) [@thiago](https://discuss.elastic.co/u/thiago)\
**Post date:** [June 19, 2017, 2:27am UTC](https://discuss.elastic.co/t/dynamic-mapper-not-working-with-default-mapping/89845/2 "2017-06-19T02:27:07Z")

</div>

Templates with conflicting patterns will get combined/merged and the order that this happens is defined by the `order` attribute. Since you have not defined an `order` attribute for `template_1` it could be the case that the order being used is actually `template_1` first then `template_all` last, so the final value of `index.mapper.dynamic` will be `false`.

Try setting `"order": 1` in template `template_1` to guarantee that the order will be `template_all` first then `template_1` last.

---

<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:** [July 17, 2017, 2:27am UTC](https://discuss.elastic.co/t/dynamic-mapper-not-working-with-default-mapping/89845/3 "2017-07-17T02:27:21Z")

</div>

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