Is it possible to write it into single ES query ? (SQL: self join)

I have problem, I want to retrieve all the document wherever same user
participate in event1 and event2.

{ "user": "user1", "event": "event1" }
{ "user": "user2", "event": "event1" }
{ "user": "user3", "event": "event2" }
{ "user": "user1", "event": "event2" }
{ "user": "user4", "event": "event1" }
{ "user": "user1", "event": "event3" }

Is it possible to write it into single query ?

SQL query, something similar like this:
select * from userTable u1, u2 where u1.user = u2.user AND ( ( u1.event =
event1 and u2.event = event2) OR ( u1.event = event2 and u2.event = event1))

Result should be:
{ "user": "user1", "event": "event1" }
{ "user": "user1", "event": "event2" }


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
To view this discussion on the web visit
For more options, visit