# Define a dynamic not\_analyzed field for a nested document

**URL:** <https://discuss.elastic.co/t/define-a-dynamic-not-analyzed-field-for-a-nested-document/14359>\
**Category:** Elasticsearch\
**Created:** [November 12, 2013, 3:50am UTC](https://discuss.elastic.co/t/define-a-dynamic-not-analyzed-field-for-a-nested-document/14359 "2013-11-12T03:50:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![11135](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/11135/32/1984_2.png) [@11135](https://discuss.elastic.co/u/11135)\
**Post date:** [November 12, 2013, 3:50am UTC](https://discuss.elastic.co/t/define-a-dynamic-not-analyzed-field-for-a-nested-document/14359/1 "2013-11-12T03:50:25Z")

</div>

I have a document like below, the "tags" field is a nested document, and I  
want to make all child field for tags document to be index = not\_analyzed.  
The problem is that field in tags will be dynamic. any tag could possible.  
So how I can define dynamic mapping for this.

{  
'level': 'info',  
'tags': {  
'content': 'Nov 6 11:07:10 ja10 Keepalived\_healthcheckers: Adding  
service [172.16.08.105:80] to VS [172.16.1.21:80]',  
'id': 1755360087,  
'kid': '2012121316',  
'mailto': 'yanping3,chunying,pengjie',  
'route': 15,  
'service': 'LVS',  
'subject': 'LVS\_RS',  
'upgrade': 'no upgrade configuration for this alert'  
},  
'timestamp': 1383707282.500464  
}

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [November 12, 2013, 5:19am UTC](https://discuss.elastic.co/t/define-a-dynamic-not-analyzed-field-for-a-nested-document/14359/2 "2013-11-12T05:19:25Z")

</div>

You can define a dynamic template where the path is every field of your  
nested type:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

"dynamic\_templates": [  
{  
"mytemplate": {  
"path\_match": "mynested.\*",  
"mapping": {  
"index" : "not\_analyzed"  
}  
}  
}  
]

Cheers,

Ivan

On Mon, Nov 11, 2013 at 7:50 PM, 朴元奎 [piaoyuankui@gmail.com](mailto:piaoyuankui@gmail.com) wrote:

> I have a document like below, the "tags" field is a nested document, and I  
> want to make all child field for tags document to be index = not\_analyzed.  
> The problem is that field in tags will be dynamic. any tag could possible.  
> So how I can define dynamic mapping for this.
> 
> {  
> 'level': 'info',  
> 'tags': {  
> 'content': 'Nov 6 11:07:10 ja10 Keepalived\_healthcheckers: Adding  
> service [172.16.08.105:80] to VS [172.16.1.21:80]',  
> 'id': 1755360087,  
> 'kid': '2012121316',  
> 'mailto': 'yanping3,chunying,pengjie',  
> 'route': 15,  
> 'service': 'LVS',  
> 'subject': 'LVS\_RS',  
> 'upgrade': 'no upgrade configuration for this alert'  
> },  
> 'timestamp': 1383707282.500464  
> }
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:07am UTC](https://discuss.elastic.co/t/define-a-dynamic-not-analyzed-field-for-a-nested-document/14359/3 "2017-07-06T02:07:46Z")

</div>


