使用两次 Siddhi CEP 查询 windows
Query with Siddhi CEP using two times windows
我正在尝试执行一个简单的查询,但需要执行两次 windows;该查询类似于尝试向在过去四个月中访问过网络产品两次以上的用户发送消息,前提是您已经在上个月发送了该产品的广告。
define stream webvisit (idClient string, idProduct string, chanel string)
from webvisit select idCliente, idProducto, canal,sum(1) as visits group by idCliente insert into visits
from visits[idProduct=='Fondos' and visits > 2]#window.time(4) insert into alert
会继续吗?
您可以执行以下操作:
define stream webvisit (idClient string, idProduct string, chanel string)
from visits[productId =='Fondos’]#window.time(4 days)
select idClient, idProduct, chanel, count(idClient) as visitCount
group by idClient
insert into visits;
from visits[visitCount > 2]
select *
insert into resultStream;
在第二个查询中,我们获取每个客户在过去 4 天内的访问次数,在最后一个查询中,我们使用次数 > 2 过滤这些结果。
编辑:
由于只有在最后一天内未发送通知才需要发送通知(假设定义为:当前时间 - 24 小时),您可以尝试以下操作:
define stream webvisit (idClient string, idProduct string, chanel string);
from webvisit[idProduct == 'Fondos']#window.time(4 days)
select idClient, idProduct, chanel, count(idClient) as visitCount
group by idClient insert into visits for current-events;
from visits[visitCount > 2]#window.time(1 day)
select idClient, idProduct, chanel, count(idClient) as hitsForClientPerDay
insert into tempStream;
from tempStream[hitsForClientPerDay < 2]
select idClient, idProduct, chanel, 'your custom message here' as advertisement
insert into advertisementStream;
第二个(1 天 window)查询跟踪过去 24 小时内生成了多少警报('hitsForClientPerDay'),最后一个查询仅在没有警报时发送广告在那段时间里有任何事情发生(请注意,当事件到来时,hitsForClientPerDay 将为 1,因为当前事件也被视为 count(),因此我们将其检查为 < 2)。
我正在尝试执行一个简单的查询,但需要执行两次 windows;该查询类似于尝试向在过去四个月中访问过网络产品两次以上的用户发送消息,前提是您已经在上个月发送了该产品的广告。
define stream webvisit (idClient string, idProduct string, chanel string)
from webvisit select idCliente, idProducto, canal,sum(1) as visits group by idCliente insert into visits
from visits[idProduct=='Fondos' and visits > 2]#window.time(4) insert into alert
会继续吗?
您可以执行以下操作:
define stream webvisit (idClient string, idProduct string, chanel string)
from visits[productId =='Fondos’]#window.time(4 days)
select idClient, idProduct, chanel, count(idClient) as visitCount
group by idClient
insert into visits;
from visits[visitCount > 2]
select *
insert into resultStream;
在第二个查询中,我们获取每个客户在过去 4 天内的访问次数,在最后一个查询中,我们使用次数 > 2 过滤这些结果。
编辑:
由于只有在最后一天内未发送通知才需要发送通知(假设定义为:当前时间 - 24 小时),您可以尝试以下操作:
define stream webvisit (idClient string, idProduct string, chanel string);
from webvisit[idProduct == 'Fondos']#window.time(4 days)
select idClient, idProduct, chanel, count(idClient) as visitCount
group by idClient insert into visits for current-events;
from visits[visitCount > 2]#window.time(1 day)
select idClient, idProduct, chanel, count(idClient) as hitsForClientPerDay
insert into tempStream;
from tempStream[hitsForClientPerDay < 2]
select idClient, idProduct, chanel, 'your custom message here' as advertisement
insert into advertisementStream;
第二个(1 天 window)查询跟踪过去 24 小时内生成了多少警报('hitsForClientPerDay'),最后一个查询仅在没有警报时发送广告在那段时间里有任何事情发生(请注意,当事件到来时,hitsForClientPerDay 将为 1,因为当前事件也被视为 count(),因此我们将其检查为 < 2)。