The value of my hippo:name property can have values with underscore in them (first_name). I want to filter a list of files whose hippo:name contains an underscore in them. My filter in my XPAth query is like this [jcr:contains(@hippo:name,"_")] and I dont think the is support for underscore characters.
Is there a way to write this query ?
Try the following:
//*[ jcr:like(@hippo:name, ‘%_%’)]
% is a wildcard for jcr:like.
_ is also a wildcard so it has to be escaped.
I don’t know if this is efficient on large datasets.
Thank you very much. The jcr:like query works very well. Thank you.
However, it looks like it is case sensitive unlike the jcr:contains. How do I make it case insensitive ?
The query below doesn’t seem to return correct results but also
jcr:like is really to be discouraged since it has an awful performance
I don’t know how to make it case insensitive.
It seems to work for me, where as jcr:contains doesn’t seem to work very well at all. On a sample data set of News documents (from essentials) I changed a hippo:name to “The medusa_news”
//*[ jcr:contains(@hippo:name, 'The medusa')]
returns a document, but
//*[ jcr:contains(@hippo:name, 'The medus')]
//*[ jcr:contains(@hippo:name, '_news')]
//*[ jcr:contains(@hippo:name, '\_news')]
These return 2 documents that end in “news” but only one has “_news”. So I don’t exactly seem to know how jcr:contains works. I gave a query that seemed to work, I disregarded performance.
Thank you very much , really appreciate it!
I think you can append a (more specific) constraint using either
jcr:lower-case function. e.g,
//element(*)[jcr:like(@myproject:title, '%\_%') and jcr:like(fn:lower-case(@myproject:title), '%bloom_reach%')]
that totally works, thanks a million!