elasticsearch scripting: how to access other buckets in histogram -
using elasticsearch 2.3.3
i have date_histogram , inside bucket_script. in script, want use aggregations on current bucket (no problem there) aggregation on previous bucket. did not see way access other buckets inside script.
am missing or not possible?
here query:
curl -xpost "http://$eshost:$esport/$index_name/_search?pretty" -d ' { "size": 0, "aggs" : { "s_price" : { "date_histogram" : { "field" : "a_date", "interval" : "month", "format" : "yyyy-mm" }, "aggs" : { "median_price": { "percentiles": { "field": "s_price", "percents": [50] } }, "median_price_change": { "derivative": { "buckets_path": "median_price.50" }}, "median_percent_change": { "bucket_script": { "gap_policy" : "insert_zeros", "buckets_path": { "price_change": "median_price_change", "price_abs": "median_price.50" }, "script": "price_change / price_abs * 100" } } } } } }'
instead of price_abs pointing current bucket value, point previous bucket value.
thanks
Comments
Post a Comment