How to do a "subquery"

Hi all

I have data like following

{ "id":1, "name":"Tom", "query":"apple"}
{ "id":2, "name":"Tom", "query":"orange"}
{ "id":3, "name":"Jack", "query":"apple"}
{ "id":4, "name":"Jack", "query":"banana"}

which query/search can i use to get:

"which queries that queried by the men who query orange"

for example:
Tom and Jack query orange
they also query apple and banana

so the result is "apple, orange, banaba"

Thanks,
Zhao Chun

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/386b9632-602d-44e2-9de7-de5bfbb5be18%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.