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

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

diff --git a/docs/Aggregation/Pipeline/SerialDifferencing.md b/docs/Aggregation/Pipeline/SerialDifferencing.md
new file mode 100644
index 0000000..5f3342e
--- /dev/null
+++ b/docs/Aggregation/Pipeline/SerialDifferencing.md
@@ -0,0 +1,54 @@
+# Serial Differencing Aggregation
+
+> More info about serial differencing aggregation is in the [official elasticsearch docs][1]
+
+Serial differencing is a technique where values in a time series are subtracted from itself at 
+different time lags or periods
+
+## Simple example
+
+```JSON
+{
+   "aggs": {
+      "my_date_histo": {                  
+         "date_histogram": {
+            "field": "timestamp",
+            "interval": "day"
+         },
+         "aggs": {
+            "the_sum": {
+               "sum": {
+                  "field": "lemmings"     
+               }
+            },
+            "thirtieth_difference": {
+               "serial_diff": {                
+                  "buckets_path": "the_sum",
+                  "lag" : 30
+               }
+            }
+         }
+      }
+   }
+}
+```
+
+And now the query via DSL:
+
+```php
+$search = new Search();
+
+$dateAggregation = new DateHistogramAggregation('my_date_histo', 'timestamp', 'day');
+$dateAggregation->addAggregation(
+    new SumAggregation('the_sum', 'lemmings')
+);
+$diffAggregation = new SerialDifferencingAggregation('thirtieth_difference', 'the_sum');
+$diffAggregation->addParameter('lag', 30);
+$dateAggregation->addAggregation($diffAggregation);
+
+$search->addAggregation($dateAggregation);
+
+$aggArray = $search->toArray();
+```
+
+[1]: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-serialdiff-aggregation.html
\ No newline at end of file
-- 
GitLab