I am trying to write an EPStatement that will match any event that does not have a specified field "similar" to another event in a sliding time window. For example only match events where "value" is at least distance 3 from any other event in the sliding window,
At t=t_0, E0={value=0} // Match
At t=t_1, E1={value=9} // Match
At t=t_2, E2={value=1} // Don't match since value is within 3 of E0.value
I am looking for a statement where I could use any expression that compares two values as the "similarity" metric. I looked at using patterns or match recognize but they don't seem to support this type of dynamic comparison to an unknown number of previous events.
select * from SomeEvent#keepall as e
having not window(*).anyOf(p => Math.abs(p.value - e.value) <= 3 and p.id != e.id)
The window(*)
holds all events. The anyOf
goes thru the window to find any that match. The p.id=e.id
excludes the current event. field id
being a unique id of the event that you may or may not have as an event property on the event.