I'm trying to get the values of a multified with my term aggregation and I'm seeing something odd. I have 2 fields, one is an array and the other is just a string. Both have a keyword field to store the keyword version of the value and a 2nd multifield that has a normalized version of it. I want for my buckets to bring both the key and the normalized version
"industries": {
"properties": {
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"normalized": {
"type": "keyword",
"ignore_above": 256,
"normalizer": "xyz_normalizer"
}
}
}
}
},
"representative": {
"properties": {
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
},
"normalized": {
"type": "keyword",
"ignore_above": 256,
"normalizer": "xyz_normalizer"
}
}
}
}
}
I had not much luck with finding a way and resorted to an aggregation term with a script, but this is where it gets strange. The following throws a array_index_out_of_bounds_exception
{
"size": 0,
"aggs": {
"platforms": {
"terms": {
"field": "industries.name.keyword",
"script": "doc['industries.name.keyword']+ ',' + doc['industries.name.normalized']"
}
}
}
}
However if I do it for my other field it works:
{
"size": 0,
"aggs": {
"platforms": {
"terms": {
"field": "industries.name.keyword",
"script": "doc['representative.keyword']+ ',' + doc['representative.normalized']"
}
}
}
}
How do I make my script capable of working for the array value as it does for the plain one?