I want to know if there is a method to write a query that can get the sum of a field value and such type of fields top 10 occurrences. For example, if I have 20 IP address in 100 documents and each document also tells me the amount of bytes sent and received by that IP at a point of time.
{ 'ip' : "192.168.0.1",
"sentbytes" : "20",
"receivebytes" : "10",
},
{ 'ip' : "183.19.22.15",
"sentbytes" : "20",
"receivebytes" : "10",
},
and so on
Is there a concept where I will get the top 10 IP's that have shared the maximum amount of send bytes and IP's that have max. receive bytes.
I know that Term aggregation will give me top 10 occurrences of IP and sum will sum up the IP's but I want to kind of merge these 2 functionalities.
Example output:
{ 'ip' : "192.168.0.1",
"sentbytes" : "100",
"receivebytes" : 200,
}
{ 'ip' : "183.19.22.15",
"sentbytes" : "20",
"receivebytes" : "10",
}
NOTE: My sentBytes and receivebytes are of type KEYWORD