# Copy\_to within multi fields

**URL:** <https://discuss.elastic.co/t/copy-to-within-multi-fields/1942>\
**Category:** Elasticsearch\
**Created:** [June 4, 2015, 3:31pm UTC](https://discuss.elastic.co/t/copy-to-within-multi-fields/1942 "2015-06-04T15:31:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![marinoc](https://avatars.discourse-cdn.com/v4/letter/m/87869e/32.png) [@marinoc](https://discuss.elastic.co/u/marinoc)\
**Post date:** [June 4, 2015, 3:31pm UTC](https://discuss.elastic.co/t/copy-to-within-multi-fields/1942/1 "2015-06-04T15:31:06Z")

</div>

All - I'm getting unexpected behavior when trying to use "copy\_to" within the multi fields option in my mappings.

Here are my mappings:

PUT [http://localhost:9200/test](http://localhost:9200/test)  
{  
"settings":{  
"index":{  
"analysis":{  
"analyzer":{  
"my\_publicationyear":{  
"type":"custom",  
"filter":[  
"my\_publicationyear"  
],  
"tokenizer":"keyword"  
}  
},  
"filter":{  
"my\_publicationyear":{  
"type":"truncate",  
"length":4  
}  
}  
},  
"number\_of\_shards":"1",  
"number\_of\_replicas":"1"  
}  
},  
"mappings":{  
"article":{  
"\_all":{  
"analyzer":"standard"  
},  
"include\_in\_all":false,  
"dynamic":"false",  
"properties":{  
"publicationDate":{  
"type":"date",  
"format":"YYYY-MM-dd",  
"fields":{  
"year":{  
"type":"string",  
"analyzer":"my\_publicationyear",  
"store":"true",  
"copy\_to":"publicationYear"  
}  
}  
},  
"publicationYear":{  
"type":"string",  
"index":"not\_analyzed"  
},  
"recordAbstract":{  
"type":"string",  
"index":"analyzed",  
"include\_in\_all":true  
},  
"recordID":{  
"type":"string",  
"index":"not\_analyzed",  
"include\_in\_all":true  
},  
"title":{  
"type":"string",  
"index":"analyzed",  
"include\_in\_all":true,  
"copy\_to":"allTitle",  
"fields":{  
"sort":{  
"type":"string",  
"index":"not\_analyzed"  
}  
}  
},  
"allTitle":{  
"type":"string",  
"index":"analyzed",  
"include\_in\_all":true  
}  
}  
}  
}  
}

And this is the document that I've indexed:

localhost:9200/test/article/123  
{  
"recordID":"123",  
"title":"This is a sample title",  
"recordAbstract":"This is a sample record abstract",  
"publicationDate":"1968-12-14"  
}

When I use the term aggregation to see what's in the multi filed (publicationDate.year), I see what I'd expect - "1968".

[http://localhost:9200/test/\_search?search\_type=count&pretty](http://localhost:9200/test/_search?search_type=count&pretty)  
{  
"aggs" : {  
"myagg" : {  
"terms" : { "field" : "publicationDate.year" }  
}  
}  
}

{  
"took": 1,  
"timed\_out": false,  
"\_shards": {  
"total": 1,  
"successful": 1,  
"failed": 0  
},  
"hits": {  
"total": 1,  
"max\_score": 0,  
"hits": []  
},  
"aggregations": {  
"myagg": {  
"doc\_count\_error\_upper\_bound": 0,  
"sum\_other\_doc\_count": 0,  
"buckets": [  
{  
"key": "1968",  
"doc\_count": 1  
}  
]  
}  
}  
}

However, when I do the same thing for the copy\_to destination field (publicationYear), I see the original value of the field.

[http://localhost:9200/test/\_search?search\_type=count&pretty](http://localhost:9200/test/_search?search_type=count&pretty)  
{  
"aggs" : {  
"myagg" : {  
"terms" : { "field" : "publicationYear" }  
}  
}  
}

{  
"took": 2,  
"timed\_out": false,  
"\_shards": {  
"total": 1,  
"successful": 1,  
"failed": 0  
},  
"hits": {  
"total": 1,  
"max\_score": 0,  
"hits": []  
},  
"aggregations": {  
"myagg": {  
"doc\_count\_error\_upper\_bound": 0,  
"sum\_other\_doc\_count": 0,  
"buckets": [  
{  
"key": "1968-12-14",  
"doc\_count": 1  
}  
]  
}  
}  
}

Is this expected behavior?

---

<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:09am UTC](https://discuss.elastic.co/t/copy-to-within-multi-fields/1942/2 "2017-07-06T00:09:35Z")

</div>


