# Using copy\_to in the dynamic templates for nested documents

**URL:** https://discuss.elastic.co/t/using-copy-to-in-the-dynamic-templates-for-nested-documents/188839
**Category:** Elasticsearch
**Created:** [July 4, 2019, 6:16am UTC](https://discuss.elastic.co/t/using-copy-to-in-the-dynamic-templates-for-nested-documents/188839 "2019-07-04T06:16:46Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![muthualagappan](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@muthualagappan](https://discuss.elastic.co/u/muthualagappan)
#### Post date: [July 4, 2019, 6:16am UTC](https://discuss.elastic.co/t/using-copy-to-in-the-dynamic-templates-for-nested-documents/188839/1 "2019-07-04T06:16:46Z")

</div>

Hi Team,

I saw the thread [https://github.com/elastic/elasticsearch/issues/12461](https://github.com/elastic/elasticsearch/issues/12461) where there is a plan to deprecate include\_in\_parent. The suggestion is to us copy\_to

Our requirement is to search for values with the field name. So there is a requirement to have a unique field name and we have seen dynamic template where we can add _"copy\_to": {name}_.

The problem is that in our nested structure we have a similar field name at multiple levels and the copy\_to copies everything to a single common field.

Kindly suggest how to use the full nested path for copy\_to.. Something like this

{  
"mappings" : {  
"dynamic\_templates": [  
{  
"field\_name": {  
"match": "\*",  
"mapping": {  
_ **"copy\_to": "{parent}.{name}"** _  
}  
}  
}  
]  
}  
}'

Also let us know if include\_in\_parent is planned to be deprecated anytime soon?

---

<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: [August 1, 2019, 6:16am UTC](https://discuss.elastic.co/t/using-copy-to-in-the-dynamic-templates-for-nested-documents/188839/2 "2019-08-01T06:16:48Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
