I'm trying to calculate the year over year percentage change, which comes down to finding the percentage change of bucket values in a histogram.
I can use the derivative aggregation as discussed here to get the simple difference. But I don't think Bucket script agg could be used for this although it's suggested there.
Then I figured the new moving function aggregation is a great fit because I can use a window of 2 with a custom function.
But the issue with that is, moving fn agg doesn't seem to consider the current bucket value as discussed in the following issue.
Although, moving fn supports scripting, the values array which is passed in contains only the bucket values prior to the current bucket as shown in the following example. The values array length is always 1 less than the bucket count.
Ideally I should be able to use a moving function like following with some size checks
"movfn": {
"moving_fn": {
"buckets_path": "b_sum",
"window": 2,
"script": "return (values[1] / values[0]) - 1"
}
}
So is there any way to get the current bucket value in a moving function agg or is there another way to implement this requirement?
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.