elasticsearch - DSL Query: Sale Amount Per Second in a Five Minute Window -
i trying total amount of sale divide 300 secs sale amount per second in 5 minute window
i far able construct query until here. there seems no way division on “total_value_five_mins”.
my elasticsearch version 2.3
tried elasticsearch docs can’t understand single one.
{ "size": 0, "query": { "aggs" : { "five_minute_data" : { "date_histogram" : { "field" : "timestamp", "interval" : "5m" }, "aggs": { "total_value_five_mins": { "sum": { "field": "sales" } } } } } }
you can use scripting in sum
aggregation this:
{ "size": 0, "query": { "aggs" : { "five_minute_data" : { "date_histogram" : { "field" : "timestamp", "interval" : "5m" }, "aggs": { "total_value_five_mins": { "sum": { "script": { "inline": "doc.sales.value / 300" } } } } } } }
wiki
Comments
Post a Comment