Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

JCR_SQL2 | On searching special character getting InvalidQueryException

Avatar

Level 2

Hi, 

I am using JCR_SQL2 Query and below is my query

String queryString = "select [jcr:path], [jcr:content/jcr:title] from [cq:Page] as a "
                + "where lower([jcr:content/jcr:title]) like '%"
                + term.toLowerCase()
                + "%' and [jcr:content/hideInSitemap] is null and isdescendantnode(a, '"
                + path
                + "')";

I have a test page and its jcr:title is  test'test , so when i search for test'test, i am getting InvalidQueryException and on other hand if am searching test-test it does not throws any exception.

Kindly suggest how to write query to search pages with title containing special character.

Thanks & Regards,

Nidhi

1 Accepted Solution

Avatar

Correct answer by
Level 10

Read this topic -- https://wiki.apache.org/jackrabbit/EncodingAndEscaping. YOU  need to escape illegal JCR characters.

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Read this topic -- https://wiki.apache.org/jackrabbit/EncodingAndEscaping. YOU  need to escape illegal JCR characters.