From 0084da4774c8efc51464a893f58405f1e62e6c9c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mantas=20Marcinkevi=C4=8Dius?= <marc.mantas@gmail.com>
Date: Mon, 29 Aug 2016 14:33:20 +0300
Subject: [PATCH] added documentation

---
 docs/Aggregation/Pipeline/StatsBucket.md | 54 ++++++++++++++++++++++++
 1 file changed, 54 insertions(+)
 create mode 100644 docs/Aggregation/Pipeline/StatsBucket.md

diff --git a/docs/Aggregation/Pipeline/StatsBucket.md b/docs/Aggregation/Pipeline/StatsBucket.md
new file mode 100644
index 0000000..98aac87
--- /dev/null
+++ b/docs/Aggregation/Pipeline/StatsBucket.md
@@ -0,0 +1,54 @@
+# Stats Aggregation
+
+> More info about stats bucket aggregation is in the [official elasticsearch docs][1]
+
+A sibling pipeline aggregation which calculates a variety of stats across all bucket of 
+a specified metric in a sibling aggregation. The specified metric must be numeric and the 
+sibling aggregation must be a multi-bucket aggregation.
+
+## Simple example
+
+```JSON
+{
+    "aggs" : {
+        "sales_per_month" : {
+            "date_histogram" : {
+                "field" : "date",
+                "interval" : "month"
+            },
+            "aggs": {
+                "sales": {
+                    "sum": {
+                        "field": "price"
+                    }
+                }
+            }
+        },
+        "stats_monthly_sales": {
+            "stats_bucket": {
+                "buckets_path": "sales_per_month>sales" 
+            }
+        }
+    }
+}
+```
+
+And now the query via DSL:
+
+```php
+$search = new Search();
+
+$dateAggregation = new DateHistogramAggregation('sales_per_month', 'date', 'month');
+$dateAggregation->addAggregation(
+    new SumAggregation('sales', 'price')
+);
+
+$search->addAggregation($dateAggregation);
+$search->addAggregation(
+    new StatsBucketAggregation('stats_monthly_sales', 'sales_per_month>sales')
+);
+
+$aggArray = $search->toArray();
+```
+
+[1]: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-stats-bucket-aggregation.html
\ No newline at end of file
-- 
GitLab