-
Aivaras Gotovskis authoredAivaras Gotovskis authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
Nested.md 944 B
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" : {
"agg_resellers" : {
"nested" : {
"path" : "resellers"
},
"aggregations" : {
"agg_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();