0
votes

how do we write query in JCR/Jackrabbit to select data using:

"where title like '%News%".

here is my structure in repository /rootNode and under root node I have many child nodes and under those child nodes i have data in which I want to search if a string matches the name or is similar to that name. please pardon me if i am not able to explain. I m new to JCR/jackrabbit. I know how to do in database example

(SELECT * FROM Customers
WHERE City LIKE 'anystring%';)

i want to accomplish similar thing in JCR. Thanks

1

1 Answers

0
votes

If you are planning to use XPATH query syntax, then the jcr:like function can be used to achieve your requirements.

/jcr:root//*[jcr:like(@jcr:title, '%News%')]

For SQL grammar, the LIKE operator can be used for the same.

select * from nt:base where jcr:title like '%News%'

For SQL2, the LIKE operator can be used again.

SELECT * FROM [nt:base] AS s WHERE s.[jcr:title] LIKE '%News%'

All the above queries are for reference only, they would run on the entire repository. But when using them for achieving the desired functionality, kindly restrict them to query within the required subtree and not the entire repo.