Count distinct with conditions using Count API

Is there a way to count distinct records/documents that match a given condition?

I am aware that _search API with cardinality aggregation can be used for this.

But is there a way this can be achieved using _count API?

Hey.

as the count API only returns the count of the search hits, but non of the aggregation results, you have to use the search API for this. You can use size: 0 to only show the aggregation results though.

--Alex

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