Copy_to within multi fields


(Chris Marino) #1

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
{
"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
{
"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
{
"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?


(system) #2