Get distinct fields for given filters

Hi ,

I want to get distinct fields in an index for given filter, for eg
for the below data
|Name|age |Country|Amount|
|Alfreds|34|Germeny|100|
|Andrew|43|U.K|333|
|Raj|54|India|4553|
|John|43|U.K|325|
|Ana|32|Mexico|56|
|Christina |22|Sweden|345|
I want to have a distinct country name when say, the amount is greater than 300.

what is the best possible way to achieve the same?

I'd do a bool with filter clause with a range query on Amount field with gt to 300.
And I'd add a terms aggregation on Country field.

What if the field for which I want distinct values is multivalued, In an another use case I want to have distinct elements from a multivalued fields for given filters, the output should contains only distinct elements across the records.

Did you try a simple test?
What do you get?

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