# Is dynamic template allowed in nested fields?

**URL:** https://discuss.elastic.co/t/is-dynamic-template-allowed-in-nested-fields/56289
**Category:** Elasticsearch
**Created:** [July 25, 2016, 11:57am UTC](https://discuss.elastic.co/t/is-dynamic-template-allowed-in-nested-fields/56289 "2016-07-25T11:57:58Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![SwethaS](https://avatars.discourse-cdn.com/v4/letter/s/e99b99/32.png) [@SwethaS](https://discuss.elastic.co/u/SwethaS)
#### Post date: [July 25, 2016, 11:57am UTC](https://discuss.elastic.co/t/is-dynamic-template-allowed-in-nested-fields/56289/1 "2016-07-25T11:57:58Z")

</div>

I see limitation on number of nested fields starting ES 2.3 - [https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking-changes-2.3.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking-changes-2.3.html)  
I have defined a mapping with dynamic template in nested field and got the below exception  
\> Caused by: MapperParsingException[Mapping definition for [\_def] has unsupported parameters: [dynamic\_templates : [{others={mapping={index=analyzed, omit\_norms=true, store=true}, match=\*}}]]]  
\> at org.elasticsearch.index.mapper.DocumentMapperParser.checkNoRemainingFields(DocumentMapperParser.java:171)  
\> at org.elasticsearch.index.mapper.DocumentMapperParser.checkNoRemainingFields(DocumentMapperParser.java:165)  
\> at org.elasticsearch.index.mapper.object.ObjectMapper$TypeParser.parseProperties(ObjectMapper.java:304)  
\> at org.elasticsearch.index.mapper.object.ObjectMapper$TypeParser.parseObjectOrDocumentTypeProperties(ObjectMapper.java:218)  
\> at org.elasticsearch.index.mapper.object.RootObjectMapper$TypeParser.parse(RootObjectMapper.java:139)  
\> at org.elasticsearch.index.mapper.DocumentMapperParser.parse(DocumentMapperParser.java:118)  
\> at org.elasticsearch.index.mapper.DocumentMapperParser.parse(DocumentMapperParser.java:99)  
\> at org.elasticsearch.index.mapper.MapperService.parse(MapperService.java:508)  
\> at org.elasticsearch.index.mapper.MapperService.merge(MapperService.java:288)  
\> at org.elasticsearch.cluster.metadata.MetaDataCreateIndexService$1.execute(MetaDataCreateIndexService.java:329)  
\> ... 8 more

Does this mean dynamic template cannot be defined in nested fields?

---

<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: [July 26, 2016, 11:19am UTC](https://discuss.elastic.co/t/is-dynamic-template-allowed-in-nested-fields/56289/2 "2016-07-26T11:19:36Z")

</div>

What does the mapping look like?

---

<div class="post-metadata">

### Author: ![SwethaS](https://avatars.discourse-cdn.com/v4/letter/s/e99b99/32.png) [@SwethaS](https://discuss.elastic.co/u/SwethaS)
#### Post date: [July 26, 2016, 1:22pm UTC](https://discuss.elastic.co/t/is-dynamic-template-allowed-in-nested-fields/56289/3 "2016-07-26T13:22:50Z")

</div>

Please find the mapping below  
\> {  
\> "work": {  
\> "mappings": {  
\> "def": {  
\> "\_all": {  
\> "enabled": false  
\> },  
\> "\_source": {  
\> "enabled": false  
\> },  
\> "\_timestamp": {},  
\> "properties": {  
\> "\_attachments": {  
\> "type": "nested",  
\> "properties": {  
\> "\_attachmentContent": {  
\> "type": "string",  
\> "norms": {  
\> "enabled": false  
\> }  
\> },  
\> "dynamic\_templates": [  
\> {  
\> "model": {  
\> "mapping": {  
\> "index": "not\_analyzed",  
\> "omit\_norms": true,  
\> "store": true  
\> },  
\> "match": "\_m\*"  
\> }  
\> }  
\> ]  
\> }  
\> }  
\> }  
\> }  
\> }  
\> }  
\> }

---

<div class="post-metadata">

### Author: ![drjz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drjz/32/972_2.png) [@drjz](https://discuss.elastic.co/u/drjz)
#### Post date: [July 27, 2016, 2:22pm UTC](https://discuss.elastic.co/t/is-dynamic-template-allowed-in-nested-fields/56289/4 "2016-07-27T14:22:19Z")

</div>

I have the same question. How can we define a dynamic template for fields which are of nested type?

---

<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 5, 2017, 10:32pm UTC](https://discuss.elastic.co/t/is-dynamic-template-allowed-in-nested-fields/56289/5 "2017-07-05T22:32:30Z")

</div>


