Narsu
Narsu

Reputation: 1

NEsper/Esper EPL event statement

Can anyone help me define the EPL statement to catch the event when the following situation occurs:

Assumming that there are events with 3 attributes - (string)Symbol, (boolean)Value, (datetime)Timestamp.

If the events have the same Symbol and have Value both true and false at the same time, should be captured. For example event1(Symbol - apple, Value - True, Timestamp - 20210614-14:00:00) and event2(Symbol - apple, Value - False, Timestamp - 20210614-14:00:00). But if the events have different Symbols (like apple and banana) should be ignored (not captured).

Thanks for any help.

Narsu

Upvotes: 0

Views: 62

Answers (1)

user3613754
user3613754

Reputation: 816

This would match two events immediately following each other (no criteria were stated as to what can come in between)

select * from MyEvent
  match_recognize (
    partition by symbol
    measures a, b
    pattern (a b)
    define
      b as b.timestamp = a.timestamp and b.value != a.value
)

Upvotes: 0

Related Questions