Using cardinality aggs, I'm able to get the distinct count of elements.
Instead of aggs, we want to get the list of matching elements using query. And this query, we would like to get it sorted using the distinct count. I looked into the function score query, but using that I'm not able to get the distinct count of a particular field.
How can I do this - to calculate the score based on the distinct count.