For my application I\'m using count API provided by elasticsearch for getting the aggregate value for my search queries in Java using RestHighLevel Client. However I\'m facing a
Following are the sample query to get the count using the aggregate function.
{
"size" : 0,
"query" : {
"term" : {
"columnid" : {
"value" : 1,
"boost" : 1.0
}
}
},
"_source" : false,
"stored_fields" : "_none_",
"aggregations" : {
"groupby" : {
"composite" : {
"size" : 10,
"sources" : [
{
"14" : {
"terms" : {
"field" : "columnid",
"missing_bucket" : true,
"order" : "asc"
}
}
}
]
}
}
}
}
Also use can translate your SQL query into kibana query using following query-
POST _xpack/sql/translate
{
"query": "SELECT COUNT(*), columnid FROM Indexname WHERE columnid=1 group by columnid ",
"fetch_size": 10
}
Please mark answer if it resolves your problem.