How to filter on unique count aggreagtion

Hi All,
I am trying to filter a unique count aggregation for values >= 1.
With normal counts, min_doc_count works fine. So for example I input string {"min_doc_count":2} in the Json input section of the bucket. But when using the unique count metric this does not seem to work. Probably I need to change the Json input, would you know how and if this is possible at all?
Thanks in advance for your time.

The min_doc_count is going to filter buckets based on the number of documents in that time range and then the metric (unique count) is calculated on top. Instead of a unique count metric would something like a sub bucket using a terms aggregation work instead?

Hi Jon,

thanks very much for your reply. Unfortunately my index does not have any "date" field type so I cannot use aggregation "Date Histogram" as in your screenshot.
In addition I really need to use the unique count because of the repetition of data in my dataset. An example to try to give the idea of what I want to do:

Data Row A:
House owner name: Tim
House location: Zurich
House type: Villa

Data Row B:
House owner name: Tim
House location: Zurich
House type: Flat

Data Row C:
House owner name: Tim
House location: London
House type: Flat

Data Row D:
House owner name: Mark
House location: London
House type: Villa

I would like to know in how many different cities an house owner has an house.

Tim count would be 2
Mark count would be 1

But in the final visualization I would like to see only the house owners with an house in more than 1 different city. Basically I would like to see only Tim in my data visualization.
Obviously ma dataset has much more details and variables so a simple exclusion of the house type field would not work.

Is there a way I can achieve this?
Sorry in advance if I was not too clear or my questions are dumb, I'm just a beginner :slight_smile:
Thanks
Giuseppe

Hello and happy new year everybody

Is there anyone who can help me with my inquiry?

Thanks
Giuseppe

Hi @mahmoud_016,

many thanks for your kind reply. I will check and let you know if it works for me!

Cheers
Giuseppe

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