# Copy\_to not copying data in nested object type

**URL:** <https://discuss.elastic.co/t/copy-to-not-copying-data-in-nested-object-type/74516>\
**Category:** Elasticsearch\
**Created:** [February 9, 2017, 2:14pm UTC](https://discuss.elastic.co/t/copy-to-not-copying-data-in-nested-object-type/74516 "2017-02-09T14:14:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amit\_Sharma1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amit_sharma1/32/13733_2.png) [@Amit\_Sharma1](https://discuss.elastic.co/u/Amit_Sharma1)\
**Post date:** [February 9, 2017, 2:14pm UTC](https://discuss.elastic.co/t/copy-to-not-copying-data-in-nested-object-type/74516/1 "2017-02-09T14:14:57Z")

</div>

copy\_to is not storing data as nested object although jobActivity is defined as nested type. If we directly aggregate on jobActivity.jobTitle field. it returns the data but nested aggregation query doesn't return any result.

I am using below query to query nested object

POST /{index\_name}/{type}/\_search  
{  
"size": 0,  
"query": {  
"match\_all": {}  
},  
"aggregations" : {  
"jobActivity" : {  
"nested": {  
"path": "jobActivity"  
},  
"aggregations":{  
"jobTitle":{  
"terms" : {  
"field" : "jobActivity.jobTitle.jobTitle\_sort",  
"size" :0,  
"order" : {  
"\_term" : "asc"  
}  
}  
}  
}  
}  
}  
}

Please find below index mapper for the field:

"appliedJob": {  
"type": "nested",  
"include\_in\_parent": true,  
"properties": {  
"jobTitle": {  
"type": "string",  
"fields": {  
"jobTitle\_sort": {  
"type": "string",  
"index": "not\_analyzed"  
}  
},  
"copy\_to": [  
"jobActivity.jobTitle"  
]  
}  
}  
},  
"jobActivity": {  
"type": "nested",  
"properties": {  
"jobTitle": {  
"type": "string",  
"fields": {  
"jobTitle\_sort": {  
"type": "string",  
"index": "not\_analyzed"  
}  
}  
}  
}  
}

---

<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:** [March 9, 2017, 2:15pm UTC](https://discuss.elastic.co/t/copy-to-not-copying-data-in-nested-object-type/74516/2 "2017-03-09T14:15:00Z")

</div>

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