I have the following elasticsearch index structure:
id|action|user_id|message_id
1| click| 1| 1
2| open| 1| 1
3| click| 2| 1
4| open| 2| 1
5| click| 1| 2
6| click| 1| 2
7| click| 3| 2
The idea is to insert records with action:'open' for every user_id-message_id that that is missing records with action:'open'. For that purpose I need to get all user_id-message_id associations only if they don't have action:'open' already.
Is it possible to create a query that returns distinct user_id-message_id records excluding user_id-message_id if table also has record with action:open and the same user_id-message_id association?
Expected result:
5| click| 2| 1
7| click| 3| 2