2

I want to find an asset under a particular path and that has a name like '%xyz%'. I referred to this page "9 JCR Queries every AEM developer should know"

Please refer to point number 7. It clearly states that I can use a combination of Name() Like '%xyz%'

APPROACH 1

So I fired a query

String jcrQuery = "SELECT * FROM [dam:Asset] WHERE NAME() LIKE '%"+conditionalSelectString+"%'";

And I go javax.jcr.UnsupportedRepositoryOperationException.

Approach 2 I found this amazing page with CQ5 that helps you construct JCR-SQL2 queries http://localhost:4502/crx/explorer/ui/search.jsp

So with the help of this I generated the query

select * from dam:Asset where jcr:path like '/content/dam/pdf/%' and contains(*, '%Slide%') 

This works fine when I fire this query on the search.jsp page of CQ5. But when I try to fire this query in a class within my bundle I get an Exception

So how do I fire a query that searches a DAM Asset by name using like and not exact name. I know that NAME can be used to find node with exact match.

How do I use name and Like together ?

Oliver
  • 6,152
  • 2
  • 42
  • 75
  • 1
    Can you post your code. It doesn't look like an issue with your query. The above query would work fine. If it is an issue with the query, you should be getting a `ParseException` I guess and not the `UnsupportedRepositoryOperationException` (not exactly sure though). – rakhi4110 Mar 18 '16 at 10:19

0 Answers0