Xpath repository query to match a string with special characters


We have a data structure called EAP:Article where there are a bunch of different subnodes and one of them is called EAP:body. That subnode only has one property hippostd:content that contains the text of the article.

We are trying to set up an xpath query that retrieves all published articles that have the following string inside the EAP:body subnode “file://”.

The following query //element(, EAP:Article)[jcr:contains(EAP:body, ‘file://’) and hippostd:state = ‘published’] gets all the articles that have the string “file://” but also “file” as it is.

I don’t know if there is a limitation with the special characters or the query is not properly built. Can anyone help us with this?

Thank you in advance.

Hello @alvgonsie,

Can you please help me with the sample output of the xpath query:
//element(*, EAP:Article)[jcr:contains(EAP:body, ‘file://’)
and also the expected result for the same.

I don’t think those characters are indexed at all. For that, you would need to implement your own lucene analyzer/tokenizer and replace default one,

Guide to Lucene Analyzers | Baeldung (you most probably would need whitespace analyzer)