Count how many values of field appears N times?


Elasticsearch 5.6

I see in the documentation how to count how many times each value of a field appears. But that is not exactly what I need.

My documents have a field myfield, of type keyword.
I need to know how many different values of myfield appear between 1 and 10 times. How many between 11 and 20 times. And so on. I don't care about their values, only their number of occurrences.

It feels to me the solution is some sort of compound aggregation, but not 100% clear how exactly, and I don't know the key words to search it myself. So any hint or direct link to documentation would be helpful.


You can use terms aggregation to get different values and their appear times. Then calculate the number of different values between 1 and 10 times, 11 and 20 yourself.

Hmm. Composite Aggregation seems to not be available in ES 5.6 :frowning:

Investigating more in the documentation, I found a page Pipelines Aggregations
If that happens to help me with this use case, I will post here how.

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