Search code examples
esper

Matching max continuous events with EPL query ESPER


I have events coming to esper and i have this query

select * from Location match_recognize (
                     measures A[0] as loc1 , count(A.locationID) as idcount
                     pattern (A{3,})
                     define
                        A as A.lat > (prev(A.lat, 1) -100) and A.lat < (prev(A.lat, 1) +100) and A.lon > (prev(A.lon, 1) -100)  and A.lon < (prev(A.lon, 1) +100)) ;

That query hits at finding a sequence of 3 close locations. I searched and found i have four continuous on my data. I want the query to hit all 4 of them. I found that queries stop when there are 3 matches because of default skip clause. I want to change that setting or find a query that hits when there are at least 3 continuous A and stop when A misses.


Solution

  • You could define a "B" that ends the search and use "pattern (A{3,} B)". This way the search only ends when the runtime finds a B. The define-clause for B would specified how the pattern ends. Use the "last" aggregation for getting the last-A values.