diff --git a/docs/Aggregation/Nested.md b/docs/Aggregation/Nested.md new file mode 100644 index 0000000000000000000000000000000000000000..f7cf99c25f922eca4dd58a4ba47c9f3f3f2aec1e --- /dev/null +++ b/docs/Aggregation/Nested.md @@ -0,0 +1,37 @@ +# Nested Aggregation + +> More info about nested aggregation is in the [official elasticsearch docs][1] + +A special single bucket aggregation that enables aggregating nested documents. + +## Simple example + +```JSON +{ + "aggregations" : { + "agg_resellers" : { + "nested" : { + "path" : "resellers" + }, + "aggregations" : { + "agg_min_price" : { "min" : { "field" : "resellers.price" } } + } + } + } +} +``` + +And now the query via DSL: + +```php +$minAggregation = new MinAggregation('min_price', 'resellers.price'); +$nestedAggregation = new NestedAggregation('resellers', 'resellers'); +$nestedAggregation->addAggregation($minAggregation); + +$search = new Search(); +$search->addAggregation($nestedAggregation); + +$queryArray = $search->toArray(); +``` + +[1]: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-nested-aggregation.html