I have a query where I'm grouping by smartphone and then by carrier. Inside these nested aggregations, I want to find the avg price, rating, and speed of each carrier for that particular smartphone. This is my current query:
{
"aggs": {
"group_by_smartphone": {
"terms": {
"field": "smartphone"
},
"aggs": {
"group_by_carrier": {
"terms": {
"field": "carrier"
},
"aggs": {
"group_by_avg_price": {
"avg": {
"field": "price"
}
}
},
"group_by_rating":{
"avg":{
"field": "rating"
}
}
}
}
}
}
}
With this current query, I'm getting an error saying:
"type": "parsing_exception", "reason": "Found two aggregation type definitions in [group_by_carrier]: [terms] and [group_by_rating]",
How can I fix this in order to display the correct results of each average?