Reputation: 1
i want to get an ES aggregation by two or more fields, but not to aggregate one by one, but to concat() these fields as a new one, and aggregate by these new one filed, so how to do it ? thanks
Upvotes: 0
Views: 2654
Reputation: 499
Although it's an old post, might be useful to someone. Something like this could work:
GET index/_search
{
"size": 0,
"query":{
"match_all": {}
},
"aggs": {
"unique_count": {
"cardinality": {
"script": {
"lang": "painless",
"source": "doc['field1'].value + '#' + doc['field2'].value"
}
}
}
}
}
Upvotes: 5