Prepare the aggregation query according to the first occurence of the events

Opensearch is as the bot says not supported here so I would recommend you reach out the the Opensearch community.

You may also want to have a look at this old post for a discussion on what seems to be a very similar problem.