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

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -