Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list
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.

2 Replies

Avatar

Correct answer by
Level 10

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