From 57cea2aa64ee389255b14c4fcd225171db85eba8 Mon Sep 17 00:00:00 2001 From: Aivaras Gotovskis <aivaras.gotovskis@ongr.io> Date: Fri, 10 Jul 2015 12:06:05 +0300 Subject: [PATCH] Add nested aggregation doc. --- docs/Aggregation/Nested.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 docs/Aggregation/Nested.md diff --git a/docs/Aggregation/Nested.md b/docs/Aggregation/Nested.md new file mode 100644 index 0000000..f7cf99c --- /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 -- GitLab