Get distinct count on a field by grouping on another field and select all rows with a condition on that count

Hi, I am very new to elastic search and I need to write a query in Elasticsearch which is equivalent to the following SQL query:

SELECT * FROM table WHERE field1 IN (SELECT field1 FROM table GROUP BY field1 HAVING COUNT(DISTINCT field2) >=3)

I checked different posts and found some information on grouping and distinct count but not exactly what I am looking. Can anyone help?

Thanks in advance.

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