# Creating a dynamic\_template with a patch\_match of arbitrary depth

**URL:** https://discuss.elastic.co/t/creating-a-dynamic-template-with-a-patch-match-of-arbitrary-depth/23085
**Category:** Elasticsearch
**Created:** [April 3, 2015, 2:36pm UTC](https://discuss.elastic.co/t/creating-a-dynamic-template-with-a-patch-match-of-arbitrary-depth/23085 "2015-04-03T14:36:00Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Brian\_Levine](https://avatars.discourse-cdn.com/v4/letter/b/82dd89/32.png) [@Brian\_Levine](https://discuss.elastic.co/u/Brian_Levine)
#### Post date: [April 3, 2015, 2:36pm UTC](https://discuss.elastic.co/t/creating-a-dynamic-template-with-a-patch-match-of-arbitrary-depth/23085/1 "2015-04-03T14:36:00Z")

</div>

I'm indexing documents with nested objects where some of the objects  
include unique ids (GUIDS). I want all such fields to be "not\_analyzed."  
The id fields always have an '\_id' suffix however, these fields can appear  
at arbitrary levels in the document hierarchy. I'm trying to come up with a  
dynamic mapping template to address this so that any field of the form  
"_\_id" regardless of the nesting depth will be marked as "not\_analyzed." I  
don't think there's a way to specify this as a single patch\_match, but I  
just wanted to confirm that I'm not missing something. In practice, I  
suppose the nesting will never go deeper than let's say, 5. So I could  
define 5 path\_match patterns like \_id, .\_id, ..\_id...etc. Although  
experience shows that the moment I do this, we'll find the need to go to 6  
levels ;-). Ideally, you'd be able to specify a path in ANT-like syntax  
e.g., \*\*/_\_id. Maybe I'll write up an enhancement request for this.

Thanks.

-b

--  
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/f545d11b-3ce0-4e27-9a00-7dc397d34043%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f545d11b-3ce0-4e27-9a00-7dc397d34043%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Brian\_Levine](https://avatars.discourse-cdn.com/v4/letter/b/82dd89/32.png) [@Brian\_Levine](https://discuss.elastic.co/u/Brian_Levine)
#### Post date: [April 7, 2015, 5:51pm UTC](https://discuss.elastic.co/t/creating-a-dynamic-template-with-a-patch-match-of-arbitrary-depth/23085/2 "2015-04-07T17:51:38Z")

</div>

> <https://github.com/elastic/elasticsearch/issues/10467>
>
> Use case:
> 
> I'm indexing documents with nested objects where some of the objects …include unique ids (GUIDS). I want all such id fields to be "not\_analyzed." The id fields always have an '\_id' suffix and these fields can appear at arbitrary levels in the document hierarchy. I'm trying to come up with a dynamic mapping template to address this so that any field of the form "\_\_id" regardless of the nesting depth will be marked as "not\_analyzed." I don't think there's a way to specify this as a single path\_match. In practice, I suppose the nesting will never go deeper than let's say, 5. So I could define 5 path\_match patterns like \*\_id, \*.\_\_id, \_.\_.\*\_id...etc. Although experience shows that the moment I do this, we'll find the need to go to 6 levels ;-). 
> 
> Ideally, you'd be able to specify a path in ANT-like syntax e.g., \*\_/\_\_id.

On Friday, April 3, 2015 at 10:36:00 AM UTC-4, Brian Levine wrote:

> I'm indexing documents with nested objects where some of the objects  
> include unique ids (GUIDS). I want all such fields to be "not\_analyzed."  
> The id fields always have an '\_id' suffix however, these fields can appear  
> at arbitrary levels in the document hierarchy. I'm trying to come up with a  
> dynamic mapping template to address this so that any field of the form  
> "_\_id" regardless of the nesting depth will be marked as "not\_analyzed." I  
> don't think there's a way to specify this as a single patch\_match, but I  
> just wanted to confirm that I'm not missing something. In practice, I  
> suppose the nesting will never go deeper than let's say, 5. So I could  
> define 5 path\_match patterns like \_id, .\_id, ..\_id...etc. Although  
> experience shows that the moment I do this, we'll find the need to go to 6  
> levels ;-). Ideally, you'd be able to specify a path in ANT-like syntax  
> e.g., \*\*/_\_id. Maybe I'll write up an enhancement request for this.
> 
> Thanks.
> 
> -b

--  
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/3242a687-9d76-4b83-a998-69a393cb5a9c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/3242a687-9d76-4b83-a998-69a393cb5a9c%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:21am UTC](https://discuss.elastic.co/t/creating-a-dynamic-template-with-a-patch-match-of-arbitrary-depth/23085/3 "2017-07-06T00:21:04Z")

</div>


