How can I perform an aggregation on multiple fields? That is I would like to list out the results of a terms aggregation on "field1" and "field2", not separately, but in the same bucket. Is it possible in elasticsearch?
As of now there is no direct way to do multi field aggregation in Elasticsearch. But you can achieve the required results using scripts as below:
{
"aggs": {
"mixed_aggs": {
"terms": {
"script": "doc['field1'].values + doc['field2'].values"
}
}
}
}
You can read more about the above case in this blog
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments