Count API with Group By field

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 situation where I need to get the aggregate based on the currency for which I need to include group by field condition. Any idea on how to add group by condition using count API in Java?

Hey,

this sounds like in can be done using the search API and an aggregation. Any reason for not doing this?

--Alex

We thought count API would improve the performance but came to know that it uses search API under the hood. So now we are trying to know if grouping is supported in count API else need to go back to search API with aggregation.

just go ahead with search API and you will be fine. The count API is simply a wrapper around a search - no performance optimization or anything happens - also there is no grouping, because there are no aggregations.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.