# Dynamic templates - Why is this configuration not working?

**URL:** <https://discuss.elastic.co/t/dynamic-templates-why-is-this-configuration-not-working/14636>\
**Category:** Elasticsearch\
**Created:** [November 28, 2013, 6:14pm UTC](https://discuss.elastic.co/t/dynamic-templates-why-is-this-configuration-not-working/14636 "2013-11-28T18:14:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tchinkatchuk](https://avatars.discourse-cdn.com/v4/letter/t/958977/32.png) [@Tchinkatchuk](https://discuss.elastic.co/u/Tchinkatchuk)\
**Post date:** [November 28, 2013, 6:14pm UTC](https://discuss.elastic.co/t/dynamic-templates-why-is-this-configuration-not-working/14636/1 "2013-11-28T18:14:42Z")

</div>

Hi all,

I am looking for help on my dynamic templates.  
I figured that this confguration is not working :  
{  
"article":  
{  
"_default_" : {  
"dynamic\_templates":  
[{  
"template\_raw":  
{  
"match" : "_\_raw",  
"mapping" :  
{  
"type" : "string",  
"index" : "not\_analyzed",  
"store" : "yes"  
}  
},  
"template\_basic": {  
"match": "_",  
"mapping": {  
"type": "{dynamic\_type}",  
"index" : "analyzed"  
}  
}  
}]  
},  
"\_all":  
{  
"enabled" : true  
},  
"\_analyzer" : {  
"default" : {  
"type" : "default"  
}  
},  
"properties":  
{  
"id":  
{  
"type":"long",  
"index": "no",  
"store":"no"  
},  
"slug":  
{  
"type":"string",  
"index": "not\_analyzed",  
"store":"no"  
},  
"code":  
{  
"type":"string",  
"index": "not\_analyzed",  
"store":"yes",  
"boost": 5.0  
}  
...  
}  
}  
}

No errors during index creation and mapping pushing.  
But my mapping does take in account this confuguration.

If I remoce the ""_default_" and setting the templates configuration on the  
parent level, i have the error on mapping definition : "MapperParsingException[A  
dynamic template must be defined with a name]".

How should I define this dynamic template ? Sorry for the noob question but  
I falied in this little stuff.

Sylvain

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/74deebd2-c847-4d57-8c0f-eea6b54d71ab%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/74deebd2-c847-4d57-8c0f-eea6b54d71ab%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Andrii\_Gakhov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrii_gakhov/32/771_2.png) [@Andrii\_Gakhov](https://discuss.elastic.co/u/Andrii_Gakhov)\
**Post date:** [December 11, 2013, 12:26pm UTC](https://discuss.elastic.co/t/dynamic-templates-why-is-this-configuration-not-working/14636/2 "2013-12-11T12:26:15Z")

</div>

Your problem is related to a mistake in the "dynamic\_template" definition. It must have the next form:

```
"dynamic_templates": [
    {
                "template_raw": {
                    "match" : "*_raw",
                    "mapping" : {
                        "type" : "string",
                        "index" : "not_analyzed",
                        "store" : "yes"
                    }
                }
    },
    {
                "template_basic": {
                    "match": "*",
                    "mapping": {
                        "type": "{dynamic_type}",
                        "index" : "analyzed"
                    }
                }
     }
]
```

So, the difference is that every dynamic template should be separated as another dict in the list of dynamic templates.

---

<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 6, 2017, 2:02am UTC](https://discuss.elastic.co/t/dynamic-templates-why-is-this-configuration-not-working/14636/3 "2017-07-06T02:02:00Z")

</div>


