Nested Aggregation
More info about nested aggregation is in the official elasticsearch docs
A special single bucket aggregation that enables aggregating nested documents.
Simple example
{
"aggregations" : {
"resellers" : {
"nested" : {
"path" : "resellers"
},
"aggregations" : {
"min_price" : { "min" : { "field" : "resellers.price" } }
}
}
}
}
And now the query via DSL:
$minAggregation = new MinAggregation('min_price', 'resellers.price');
$nestedAggregation = new NestedAggregation('resellers', 'resellers');
$nestedAggregation->addAggregation($minAggregation);
$search = new Search();
$search->addAggregation($nestedAggregation);
$queryArray = $search->toArray();