I'm pretty new in NEsper/Esper. I want to catch the event when two event occur less than 3 seconds, in other words when the timestamp difference between two events is smaller than 3 seconds. How can I define the EPL statement? For example, the event is a Tick (which contains attributes- symbol, price and timestamp). When a Tick occurs after previous Tick less than 3 seconds, the second Tick should be captured. How can I write the EPL statement "select * from StockTick(symbol='anySymbol')...."? Thanks in advance. Narsu
Asked
Active
Viewed 73 times
1 Answers
0
There are quite a few ways. Lets use match-recognize. It seems to do what you want.
select * from SymbolTick
match_recognize (
partition by symbol
measures E1 as e1, E2 as e2
pattern (E1 E2)
define
E2 as E1.timestamp.before(E2.timestamp, 3)
)
You can read up on "before" and "after". I think maybe I didn't get it right so please check and test. For numeric timestamps one could instead do "E2.timestamp - E1.timestamp <= 3000".

user650839
- 2,594
- 1
- 13
- 9
-
Hey, thanks for your reply. I've tried your suggestion but got an additional Debug: Methode: StatementAIFactoryProvider_a005f40a456a9945474e4589a045a04a1e67c126_0.M18, Codegen: target = CurrentTimestamp... How can I avoid this Debug message? Could you hep me? – Narsu Oct 07 '20 at 12:17
-
what is a "debug"? are you taking about debug level logging? – user650839 Oct 08 '20 at 02:53
-
it comes the message in console when I test it in debug mode - Debug: Methode: StatementAIFactoryProvider_a005f40a456a9945474e4589a045a04a1e67c126_0.M18, Codegen: target = CurrentTimestamp... – Narsu Oct 08 '20 at 05:02
-
"test it in debug mode"? you Java app? All debug messages can be ignored. Debug messages are for consumption when interested what is going on internally and would be of no use to you. – user650839 Oct 08 '20 at 13:43