简体   繁体   English

SiddhiQL模式和窗口查询

[英]SiddhiQL Pattern and Window Query

I am trying to write a simple siddhi query which detects a pattern eg: "Ice" "cream" "x" "y" "apple" "water" 我正在尝试编写一个简单的siddhi查询,以检测一种模式,例如:“冰”,“奶油”,“ x”,“ y”,“苹果”,“水”

where events Ice & cream both should be together and apple water should be together and xy are any random values in the window.length(6) 其中应将冰淇淋和冰淇淋放在一起,将苹果水放在一起,并且xy是window.length(6)中的任何随机值

problem is the following query is not restricting the window.length(6) how can i achieve this? 问题是以下查询不限制window.length(6)如何实现呢?

from every (( s1=windowedStream[s1.val=='ice']-> s2= windowedStream[s2.val=='cream'] )
            -> ( a1=windowedStream[a1.val=='apple'] -> a2 = windowedStream[a2.val =='water'] ))
select s1.meta_timestamp, s1.val
insert into filteredStream

As per the existent notations, Siddhi allows you to restrict a pattern based on a time window only. 按照现有的表示法,Siddhi允许您仅基于时间窗口限制模式。 Please refer the following. 请参考以下内容。

https://docs.wso2.com/display/CEP420/SiddhiQL+Guide+3.1#SiddhiQLGuide3.1-Pattern https://docs.wso2.com/display/CEP420/SiddhiQL+Guide+3.1#SiddhiQLGuide3.1-Pattern

As a workaround to restricting the patterns based on a length window, you may introduce a 3rd attribute called index to the "windowedStream", where index reflects the order of event arrival (ie index of the 1st event is 1, index of the 2nd event is 2 and so on). 作为一种基于长度窗口限制模式的解决方法,您可以在“ windowedStream”中引入一个名为index的第3个属性,其中index反映事件到达的顺序(即,第一个事件的索引为1,第二个事件的索引是2,依此类推)。 Then the following query would capture the patterns occurring within a length window of 6 events. 然后,以下查询将捕获在6个事件的长度窗口内发生的模式。

from every (( s1=tempStream[s1.val=='ice']-> s2= tempStream[s2.val=='cream'] )
        -> ( a1=tempStream[a1.val=='apple'] -> a2 = tempStream[a2.val =='water' and a2.index- s1.index <= 6]))
select s1.meta_timestamp, s1.val
insert into filteredStream;

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM