From 9f4b188b5f823c0b54910b92cb695abf1a894714 Mon Sep 17 00:00:00 2001
From: Aivaras Gotovskis <aivaras.gotovskis@ongr.io>
Date: Wed, 8 Jul 2015 16:12:44 +0300
Subject: [PATCH] Add children aggregation doc.

---
 docs/Aggregation/Children.md | 43 ++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 docs/Aggregation/Children.md

diff --git a/docs/Aggregation/Children.md b/docs/Aggregation/Children.md
new file mode 100644
index 0000000..4358561
--- /dev/null
+++ b/docs/Aggregation/Children.md
@@ -0,0 +1,43 @@
+# Children Aggregation
+
+> More info about children aggregation is in the [official elasticsearch docs][1]
+
+A special single bucket aggregation that enables aggregating from buckets on parent
+document types to buckets on child documents.
+
+## Simple example
+
+```JSON
+{
+    "aggregations": {
+        "agg_author_count": {
+            "children": {
+                "type": "answer"
+            },
+            "aggregations": {
+                "agg_top_names": {
+                    "terms": {
+                        "field": "owner.display_name"
+                    }
+                }
+            }
+        }
+    }
+}
+```
+
+And now the query via DSL:
+
+```php
+$termsAggregation = new TermsAggregation('top_names', 'owner.display_name');
+
+$childrenAggregation = new ChildrenAggregation('author_count', 'answer');
+$childrenAggregation->addAggregation($termsAggregation);
+
+$search = new Search();
+$search->addAggregation($childrenAggregation);
+
+$queryArray = $search->toArray();
+```
+
+[1]: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-children-aggregation.html
-- 
GitLab