# Dynamic\_templates - is path\_match on subfield possible?

**URL:** https://discuss.elastic.co/t/dynamic-templates-is-path-match-on-subfield-possible/15713
**Category:** Elasticsearch
**Created:** [February 11, 2014, 2:32am UTC](https://discuss.elastic.co/t/dynamic-templates-is-path-match-on-subfield-possible/15713 "2014-02-11T02:32:19Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![seallison](https://avatars.discourse-cdn.com/v4/letter/s/4af34b/32.png) [@seallison](https://discuss.elastic.co/u/seallison)
#### Post date: [February 11, 2014, 2:32am UTC](https://discuss.elastic.co/t/dynamic-templates-is-path-match-on-subfield-possible/15713/1 "2014-02-11T02:32:19Z")

</div>

Is it possible to use path\_match to consider sub fields as criteria in  
applying the template?

For example, I have a dynamic template like this, but it isn't really what  
I want:

"dynamic\_templates": [  
{  
"nested\_property\_attributes": {  
"match\_mapping\_type": "object",  
"path\_match": "\*.value",  
"mapping": {  
"type": "nested",  
"include\_in\_parent": true  
}  
}  
}  
]

In my data, what is under the path \*.value could be a lot of different  
things. If there is a property named 'ranking' under .value, then I want  
to index it as a nested type. Otherwise, I don't want the template applied.

For example: I want the dynamic template to apply to the path  
"foo.bar.value" if and only if there is a "foo.bar.value.ranking" field.

Is there any way to express this? Maybe using "match\_pattern": "regex" ?

--  
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/c005b3c7-2fe0-431f-8f0f-cff1fd32b02a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c005b3c7-2fe0-431f-8f0f-cff1fd32b02a%40googlegroups.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, 1:51am UTC](https://discuss.elastic.co/t/dynamic-templates-is-path-match-on-subfield-possible/15713/2 "2017-07-06T01:51:17Z")

</div>


