Search code examples
complex-event-processingesperepl

Opposite of lastUnique()


New to Esper and EPL in general, i have two use cases which are basically the opposites of oneanother. First I need to catch all unique events in a timewindow, using firstunique(*parameters*).win:time(*time*).

Now what I need to do is the exact opposite, basically catch all events that arrive in that window and that are NOT thrown by that statement, basically all the duplicates.

How can I achieve this ? Thanks !


Solution

  • I've actually found a solution, it involves using unique id's for incoming events on top of comparing their parameters.

    The query looks something like this :

    select * from Event a where exists (select * from Event.std:firstUnique(*parameters*).win:time(*time*) b where a.eventId <> b.eventId)
    

    This solves the problem I had where the exists method would return every event (duplicates and unique events) because the window in the subquery would be filled first.