I'm trying to determine if there's a way to create a custom Predicate to handle searches for text that contains accented characters.
The problem I am trying to solve is that I have the string "Montréal" stored in the JCR, and want it to show up if my query contains a search for "Montreal" or even "Montre".
I am trying to use the XPATH function fn:replace to do something like this:
replace('Montréal', '[éè]+', 'e')
Here's an example xpath query (run using the query tool in the CRX/DE):
/jcr:root/content/dam/mysite/en//*
[
(@jcr:primaryType = 'dam:AssetContent' and jcr:like(fn:replace(fn:lower-case(data/master/@city), '[éè]+', 'e'),'%montre%'))
]
However, when I attempt to use it, I get the error:
expected: jcr:like | jcr:contains | jcr:score | xs:dateTime | fn:lower-case | fn:upper-case | fn:name | rep:similar | rep:spellcheck | rep:suggest
Is there some way to enable the replace function?
I had faced a similar issue.
I will explain what I did to overcome that.
The requirement : There is a search bar, and in that user were using accented chars.
The problem : same. jcr:like & fn:replace didn't work.
What I did was, sent the search param as it is intp the backend (Java) through servlet, as I was building queries through a service there. Then I just encoded them in base64, and added the same in the query, as AEM keeps non-english chars in base64 encoded values.
Then just decoded the results in the FE ( but you can do that in Java as well.)