How to get data from Elasticsearch like SQL self join

I have a Elasticsearch query.

I can see the data this URL http://localhost:9200/foobar/logs/_search

But I want to get data doing a self join. I know how to do it in mysql.

But I am not sure how to do it in elasticsearch query.

Please advise.

USE foobar;
 SELECT From_unixtime(Truncate(Unix_timestamp(entry_date) / 300, 0) * 300) AS "every_5_mins",
        t2.transactionId,
        t1.eventName,
        COUNT(*)
 FROM logs t1
 LEFT JOIN foobar.logs t2
    ON t2.transactionId = t1.transactionId
   AND t2.eventType = "done"
 WHERE t1.eventName = "register"
 GROUP BY every_5_mins

You can't do joins in nosql, which includes ES.
You either need to add this data when indexing or look at nesting or parent/child.