Skip to Content
5
Sep 30, 2014 at 11:24 AM

Escaping special characters in FlexibleSearch queries

3208 Views

How can I escape special characters (e.g. "{", "}" or "?") in FlexibleSearch queries?

E.g. I want to run

SELECT * FROM {Order} WHERE {attribute} REGEXP 'some regexp with ?, { or }'

(the REGEXP operator is MySQL syntax).

That doesn't work, because Hybris interprets those characters and complains about that, even inside of string literals. That looks like a bug to me. How can I escape those characters?

I know that I could use a bind variable in this case, but how would it work without a bind variable?