Here is my doc type: vehicles is a nested type.
document1 -
{
"customerAge": 30,
"vehicles": [
{
"brand": "Altima",
"year": 2005
},
{
"brand": "Corolla",
"year": 2006
},
{
"brand": "Camry",
"year": 2005
}
]
}
document2 -
{
"customerAge": 50,
"vehicles": [
{
"brand": "Altima",
"year": 2009
},
{
"brand": "Corolla",
"year": 2010
}
]
}
I am trying to create buckets of vehicle brand and calculate the averages of customer age. So in this example "Altima" bucket's average customer age will be 40.
I tried this query and the averages are null.
Could someone please help what am I doing incorrectly?
{
"size": 0,
"aggs": {
"nestedtop": {
"nested": {
"path": "vehicles"
},
"aggs": {
"testagg": {
"terms": {
"field": "vehicles.brand"
},
"aggs": {
"filterx3939d": {
"filter": {
"match_all": {}
},
"aggs": {
"filterx3939d": {
"min": {
"field": "customerAge"
}
}
}
}
}
}
}
}
}
}