nest - Elasticsearch - how to get sum of field with terms? -


i'm trying sum of field, term (lets say, number of files of specific user id).

first tried:

_mainmanager.client.search<object>             (q => q             .type("mail")             .filter(c => c.term("sentmail_sender_id", userid))             .aggregations(a => a.terms("sum", g => g.field("sentmail_upload_files_count")))             .size(1)); 

but no luck in agg property :(

_mainmanager.client.search<object>             (q => q             .type("mail")             .aggregations(a => a.filter("fil", b => b.filter(c => c.term("sentmail_sender_id", userid))).sum("sum", f => f.field("sentmail_upload_files_count")))); 

but again, no luck there. can help?

the following code gives result need thing:

put /mail/message/1 {   "sentmail_sender_id":1,   "sentmail_upload_files_count":10 }  put /mail/message/2 {   "sentmail_sender_id":1,   "sentmail_upload_files_count":2 }  put /mail/message/3 {   "sentmail_sender_id":2,   "sentmail_upload_files_count":7 }  /mail/_search?search_type=count {   "query": {     "filtered": {       "filter": {         "term": {           "sentmail_sender_id": 1         }       }     }   },   "aggs": {     "total": {       "stats": {         "field": "sentmail_upload_files_count"       }     }   } } 

the response is:

"aggregations": {       "total": {          "count": 2,          "min": 2,          "max": 10,          "avg": 6,          "sum": 12       }    } 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -