with query conditions, I filtered out only one doc, part of the doc _source is :
"_source": { "event": [ { "time": 1520252057459, "duration": 1876, "speed": 0, "event_name": "firstBufferingEnd", "detail": "", "cdn_ip": "" }, { "time": 1520252060460, "duration": 0, "speed": 207445, "event_name": "networkSpeed", "detail": "", "cdn_ip": "" }, { "time": 1520252062460, "duration": 0, "speed": 96871, "event_name": "networkSpeed", "detail": "", "cdn_ip": "" }, { "time": 1520252064460, "duration": 0, "speed": 0, "event_name": "networkSpeed", "detail": "", "cdn_ip": "" },
query body is as follow , I got the avg value of speed, but the value is obvious wrong, how can I exclude out those dirty events such as the "firstBufferingEnd" ?
{ "query": { "nested": { "path": "event", "query": { "bool": { "must": [ { "range": { "event.speed": { "gt":10000000 } } }, { "terms": { "event.event_name": [ "networkSpeedReport", "networkSpeed" ] } } ] } } } }, "aggs":{ "gg":{ "nested": { "path":"event" }, "aggs":{ "gg":{ "avg":{ "field":"event.speed" } } } } } }
pictures are :