Retrieve all unique values that have a common property


I have an index with the following mapping:

{"name":{"type":"keyword"}, "eat":{"type":"keyword"} }

For example, in this index there are the following documents:

{ "name":"andrew","eat":"banana"}
{ "name":"andrew","eat":"apple"}
{ "name":"john","eat":"banana"}
{ "name":"john","eat":"pear"}
{ "name":"george","eat":"banana"}

I need to retrieve all names that have in common a series of properties (for example, all names that have eaten "banana" AND "apple" -> In the above example, the only response is "andrew").

Is there a possibility to write such a query in Elasticsearch?

Thank you,


Thank you.

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