I'm able to send HTTP POST
requests individually for sum
& groupby
using aggs
in order to filter data from the index which I created through logstash
.
This is how I tried querying for groupby
:
"aggs":{
"total":{
"terms":{
"field":"responsecode"
},
"aggs":{
"grades_count":{
"value_count":{
"script":"Integer.parseInt(doc['responsecode'].value)"
}
}
}
}
}
And this is how I tried querying for sum
:
"aggs":{
"total":{
"terms":{
"field":"userid"
},
"aggs":{
"grades_count":{
"value_count":{
"script":"doc['userid'].value"
}
}
}
}
}
So what I need now is to have both of them in a single aggs
so that I can get both the sum and the group by results.
This is the MySQL
query which i'm trying to apply it in elasticsearch
:
select userId, sum(chargeAmount+0) from sb_api_response_summary where group by userId;
Where am i going wrong? Any help could be appreciated.