Query documents with a greater value than the average in ElasticSearch -


i have messages in elasticsearch. have sender of message , length of message in 2 different fields. can average message length grouped message sender following query:

post /document/_search?pretty {     "aggs": {         "app": {         "terms": {             "field": "message_sender"         },             "aggs": {                 "avg_length": {                     "avg": {                         "script" : "doc['message_length'].values[0]?.tointeger()"                     }                 }             }         }     } } 

(note: know looks weird, length of message stored string, that's why have convert integer.)

my problem is: how can list out messages longer average of group? if sender_1's average message length 100, list out messages greater that.

i trying use selector bucket no results. i'm asking how can have feature similar sql having in elasticsearch.

this not possible. might at: https://github.com/elastic/elasticsearch/issues/4404 feature discussed. implemented pipeline aggregations might not want here.

you should query 2 times. first average , messages.


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -