Why Aggregations moving_avg dont compute first bucket data?


(gnepud) #1

Hi,

I want to get a last 12 month avg with aggregation moving avg like below example.
Every values in month [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
I got a result by aggregation moving avg [null, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6]
but i want to my result like [1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5]

Version elasticsearch: 2.2
search:
{ "query": { "match": { "indicator": { "query": "oee_steam", "type": "phrase" } } }, "aggs": { "last_12_months": { "date_histogram": { "field": "date", "interval": "1M", "format": "year_month", "time_zone": "+0100", "min_doc_count": 0 }, "aggs": { "month_avg": { "avg": { "field": "value" } }, "the_movavg": { "moving_avg": { "buckets_path": "month_avg", "window": 12 } } } } } }
resulat:
{ "took": 6, "timed_out": false, "_shards": { "total": 5, "successful": 5, "failed": 0 }, "hits": { "total": 427, "max_score": 0, "hits": [] }, "aggregations": { "last_12_months": { "buckets": [ { "key_as_string": "2015-01", "key": 1420066800000, "doc_count": 31, "month_avg": { "value": 1.0036290249516886 } }, { "key_as_string": "2015-02", "key": 1422745200000, "doc_count": 28, "month_avg": { "value": 0.9984788341181619 }, "the_movavg": { "value": 1.0036290249516886 } }, { "key_as_string": "2015-03", "key": 1425164400000, "doc_count": 32, "month_avg": { "value": 0.9724848084151745 }, "the_movavg": { "value": 1.0010539295349252 } }, { "key_as_string": "2015-04", "key": 1427842800000, "doc_count": 30, "month_avg": { "value": 1.0054521600405375 }, "the_movavg": { "value": 0.991530889161675 } } ] } } }

I havnt the_movavg value for my first buckets value.

The question is why aggregation moving avg dont compute first value but begin always second value ?
And How to get a result like i wanted ?

Thanks and sorry my English is poor.


(system) #2