I have a query written as -
from xyzStream [str:contains(name,'John') or str:contains(name,'Peter') or str:contains(name,'Sandy') ]
select name
insert into outputStream
but now i want to make an enhancement where i pass the filter substring that matched. Like for example if str:contains(name,'John') returns true, insert 'John' in output stream.
Is there a way to do it in SiddhiQL?
As of now, this is not supported, however you can do the same in the select clause with str:contains and ifthenElse,
from xyzStream [str:contains(name,'John') or str:contains(name,'Peter') or str:contains(name,'Sandy') ]
select name,
ifthenElse(str:contains('John'), 'John', ifThenElse(str:contains('Peter'), 'Peter', 'Sandy')) as matchedString
insert into outputStream
See example on ifThenElse function for more details