# Dynamic Templates & Static Mappings

**URL:** https://discuss.elastic.co/t/dynamic-templates-static-mappings/3822
**Category:** Elasticsearch
**Created:** [January 24, 2011, 1:57pm UTC](https://discuss.elastic.co/t/dynamic-templates-static-mappings/3822 "2011-01-24T13:57:52Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Jan\_Fiedler](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jan_fiedler/32/2518_2.png) [@Jan\_Fiedler](https://discuss.elastic.co/u/Jan_Fiedler)
#### Post date: [January 24, 2011, 1:57pm UTC](https://discuss.elastic.co/t/dynamic-templates-static-mappings/3822/1 "2011-01-24T13:57:52Z")

</div>

I am using static mapping definitions (i.e. "dynamic" = "false") in  
order to have field level control over what fields go into the index.  
Reason is that I get rather large documents from the client side and  
only need to index a small subset of fields. I now need to support  
custom, dynamic fields (marked by a special field name prefix) added  
by the client. My plan was to use the dynamic templates feature to  
describe the names of dynamic fields and their mapping.

It seems that this approach does not work as dynamic templates only  
seem to be applied for dynamic mappings. Is this true? If yes, how can  
I limit the dynamic mapping capability to a subset of my fields?

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [January 24, 2011, 7:16pm UTC](https://discuss.elastic.co/t/dynamic-templates-static-mappings/3822/2 "2011-01-24T19:16:34Z")

</div>

Yes, setting dynamic to false will not enable dynamic templates to basically be executed (as it is considered a dynamic introduction of new mapping). Open a feature request, it can be implemented, though, I think that it might make more sense, if you have control over what is sent over the elasticsearch, to strip the data that is not to be indexed.

Also note, that even though it is not indexed as a dynamic field, it will still be stored in the \_source, as the \_source is the document sent as is.

-shay.banon  
On Monday, January 24, 2011 at 3:57 PM, Jan Fiedler wrote:

> I am using static mapping definitions (i.e. "dynamic" = "false") in  
> order to have field level control over what fields go into the index.  
> Reason is that I get rather large documents from the client side and  
> only need to index a small subset of fields. I now need to support  
> custom, dynamic fields (marked by a special field name prefix) added  
> by the client. My plan was to use the dynamic templates feature to  
> describe the names of dynamic fields and their mapping.
> 
> It seems that this approach does not work as dynamic templates only  
> seem to be applied for dynamic mappings. Is this true? If yes, how can  
> I limit the dynamic mapping capability to a subset of my fields?

---

<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:13am UTC](https://discuss.elastic.co/t/dynamic-templates-static-mappings/3822/3 "2017-07-06T04:13:18Z")

</div>


