# Copy\_to and nested field type

**URL:** <https://discuss.elastic.co/t/copy-to-and-nested-field-type/83215>\
**Category:** Elasticsearch\
**Created:** [April 21, 2017, 1:34pm UTC](https://discuss.elastic.co/t/copy-to-and-nested-field-type/83215 "2017-04-21T13:34:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nejra](https://avatars.discourse-cdn.com/v4/letter/n/8dc957/32.png) [@nejra](https://discuss.elastic.co/u/nejra)\
**Post date:** [April 21, 2017, 1:34pm UTC](https://discuss.elastic.co/t/copy-to-and-nested-field-type/83215/1 "2017-04-21T13:34:01Z")

</div>

Hi,

I have difficulty with copy\_to and nested field. I'm trying to copy some field value from original document to nested document, and as I can see from stored\_fields, it has been copied successfully. The problem appears when I try to query that "copied\_to" field - it returns zero results although I know there are lots of documents that match the query. Does anybody know what am I missing?

Here is my mapping:  
{  
"mappings": {  
"property": {  
"properties": {  
"bedrooms": {  
"type": "byte",  
"copy\_to": "discount.bedrooms"  
},  
"discount": {  
"type": "nested",  
"properties": {  
"value": {"type": "integer"},  
"bedrooms": {"type": "byte"}  
}  
}  
}  
}  
}  
}

GET /\_search  
{  
"query": {  
"nested": {  
"path": "discount",  
"query": {  
"term": {  
"discount.bedrooms": 5  
}  
}  
}  
}  
}

---

<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:** [May 19, 2017, 1:48pm UTC](https://discuss.elastic.co/t/copy-to-and-nested-field-type/83215/2 "2017-05-19T13:48:27Z")

</div>

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