xpath query and special characers | Community
Skip to main content
broman__pl
New Participant
October 16, 2015
Solved

xpath query and special characers

  • October 16, 2015
  • 1 reply
  • 1074 views

I try to nodes with property that contains some text with special character like ? + and !

I have 4 nodes

/tmp/exclamation[@prop="value with!"]
/tmp/plus[@prop="value with+"]
/tmp/question[@prop="value with?"]
/tmp/string[@prop="value with string"]

/jcr:root/tmp//*[(jcr:contains(@prop, 'with') )] return me all 4 nodes
/jcr:root/tmp//*[(jcr:contains(@prop, 'with\!') )] return me all 4 nodes
/jcr:root/tmp//*[(jcr:contains(@prop, 'with\?') )] return me all 4 nodes
/jcr:root/tmp//*[(jcr:contains(@prop, 'with\+') )] return me all 4 nodes

How I should correctly escape ! + ? to get only node that mach my search criteria?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Sham_HC

The default analyzer used in CQ does not index special characters, and just create separate tokens in Lucene for words containing them. Use different LuceneAnalyzers per your need for your property & verify. 

1 reply

Sham_HC
Sham_HCAccepted solution
New Participant
October 16, 2015

The default analyzer used in CQ does not index special characters, and just create separate tokens in Lucene for words containing them. Use different LuceneAnalyzers per your need for your property & verify.