# Dynamic template for all types

**URL:** <https://discuss.elastic.co/t/dynamic-template-for-all-types/4304>\
**Category:** Elasticsearch\
**Created:** [April 27, 2011, 3:09pm UTC](https://discuss.elastic.co/t/dynamic-template-for-all-types/4304 "2011-04-27T15:09:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jacorob](https://avatars.discourse-cdn.com/v4/letter/j/dec6dc/32.png) [@jacorob](https://discuss.elastic.co/u/jacorob)\
**Post date:** [April 27, 2011, 3:09pm UTC](https://discuss.elastic.co/t/dynamic-template-for-all-types/4304/1 "2011-04-27T15:09:48Z")

</div>

If I understand the dynamic template examples correctly (http://  
[www.elasticsearch.org/guide/reference/mapping/root-object-type.html](http://www.elasticsearch.org/guide/reference/mapping/root-object-type.html))  
it appears that you need to specify the type that the dynamic\_template  
applies to.

For example,  
{  
"person" : {  
"dynamic\_templates" : [  
{  
"store\_generic" : {  
"match" : "\*",  
"mapping" : {  
"store" : "yes"  
}  
}  
}  
]  
}  
}

This limits the dynamic template to the "person" type. Is there a way  
to specify a dynamic template that will apply to all types? Something  
akin to the "\_all" option when specifying the index/inidices that the  
template will apply to.

The reason I ask is because I create new types on the fly. I can add a  
new dynamic mapping each time I create a new type, but I was hoping  
there was a feature I was missing.

Thanks,  
Bob

---

<div class="post-metadata">

**Author:** ![jacorob](https://avatars.discourse-cdn.com/v4/letter/j/dec6dc/32.png) [@jacorob](https://discuss.elastic.co/u/jacorob)\
**Post date:** [April 27, 2011, 3:13pm UTC](https://discuss.elastic.co/t/dynamic-template-for-all-types/4304/2 "2011-04-27T15:13:09Z")

</div>

Of course, as soon as I sent this I figured out what I needed. I just need  
to specify "_default_" for the type.

Bob

On Wed, Apr 27, 2011 at 10:09 AM, Bob [jacorob@gmail.com](mailto:jacorob@gmail.com) wrote:

> If I understand the dynamic template examples correctly (http://  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/root-object-type.html))  
> it appears that you need to specify the type that the dynamic\_template  
> applies to.
> 
> For example,  
> {  
> "person" : {  
> "dynamic\_templates" : [  
> {  
> "store\_generic" : {  
> "match" : "\*",  
> "mapping" : {  
> "store" : "yes"  
> }  
> }  
> }  
> ]  
> }  
> }
> 
> This limits the dynamic template to the "person" type. Is there a way  
> to specify a dynamic template that will apply to all types? Something  
> akin to the "\_all" option when specifying the index/inidices that the  
> template will apply to.
> 
> The reason I ask is because I create new types on the fly. I can add a  
> new dynamic mapping each time I create a new type, but I was hoping  
> there was a feature I was missing.
> 
> Thanks,  
> Bob

---

<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, 4:07am UTC](https://discuss.elastic.co/t/dynamic-template-for-all-types/4304/3 "2017-07-06T04:07:31Z")

</div>


