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

SOLVED

Unable to create query with querybuilder

Avatar

Level 4

Hello,

 

for a project I have following folder structure:

/content/sites/dam/pic/0/111

/content/sites/dam/pic/0/11

content/sites/dam/pic/1/02

/content/sites/dam/pic/2/2222

 

The following x-path query works for me to grab the name of last subfolders with two characters in name: /jcr:root/content/sites/dam/pic/*/*/element(*,sling:OrderedFolder)[jcr:like(fn:name(),'__')]

 

I read lots of page whose explained the syntax and provided examples for query builder. It only accept one level of subnodes, even I set value of p.depth greater than one. My question: What is the conversion from above xpath query into one for querybuilder?

 

Thanks in advance.

 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Created similar folder structure in DAM as shown in below screenshot -

Using xpath query , getting below result -

DEBAL_DAS_0-1651584856891.png

 

Here is the query builder query -

 

path=/content/dam/demo/pic
type=sling:Folder
nodename=??
p.limit=-1

Result -

 

DEBAL_DAS_1-1651584955463.png

 

Useful information has given here -

  • nodename: This is used to search exact nodenames for the result set. It allows few wildcards like: nodename=text* will search for this and any character after it . nodename=text? will search for all records that starts with text but will not return result that contains only text. (Resolves to NodenamePredicateEvaluator).

Note:- During conversion to Xpath query * is converted to % and ? is converted to _ . For Example ‘metadata%’ (metadata node is considered, will return result for  metadata,metadata1,metadata2 etc) but for ‘metadata_’ (metadata node is ignored, will only return result for metadata1, metadata2). Choose your wildcards very wisely. Hope it clears your doubt.

 

http://www.aemcq5tutorials.com/tutorials/adobe-aem-cq5-tutorials/aem-query-builder/

 

Hope this will help.

View solution in original post

6 Replies

Avatar

Correct answer by
Community Advisor

Created similar folder structure in DAM as shown in below screenshot -

Using xpath query , getting below result -

DEBAL_DAS_0-1651584856891.png

 

Here is the query builder query -

 

path=/content/dam/demo/pic
type=sling:Folder
nodename=??
p.limit=-1

Result -

 

DEBAL_DAS_1-1651584955463.png

 

Useful information has given here -

  • nodename: This is used to search exact nodenames for the result set. It allows few wildcards like: nodename=text* will search for this and any character after it . nodename=text? will search for all records that starts with text but will not return result that contains only text. (Resolves to NodenamePredicateEvaluator).

Note:- During conversion to Xpath query * is converted to % and ? is converted to _ . For Example ‘metadata%’ (metadata node is considered, will return result for  metadata,metadata1,metadata2 etc) but for ‘metadata_’ (metadata node is ignored, will only return result for metadata1, metadata2). Choose your wildcards very wisely. Hope it clears your doubt.

 

http://www.aemcq5tutorials.com/tutorials/adobe-aem-cq5-tutorials/aem-query-builder/

 

Hope this will help.

Avatar

Level 4

Thanks for answer. I tried it and it doesn't work either. I always get following message:

 

The query read or traversed more than 100000 nodes. To avoid affecting other tasks, processing was stopped.

Cannot serve request to /libs/cq/search/content/querydebug.html in /libs/cq/search/components/querydebug/querydebug.jsp

Exception:

java.lang.UnsupportedOperationException: The query read or traversed more than 100000 nodes. To avoid affecting other tasks, processing was stopped.

 It will work if I extend the given path with additional layers until last to next. Is there a difference between "OrderedFolder" and "Folder"?

Avatar

Community Advisor

I have created sling:OrderedFolder under /content/dam/we-retail/en/pic as shown in below screenshot -

 

DEBAL_DAS_0-1651588753490.png

Below query is working perfectly without any issue with sling:OrderedFolder-

 

path=/content/dam/we-retail/en/pic
type=sling:OrderedFolder
nodename=??
p.limit=-1

DEBAL_DAS_1-1651588843670.png

 

Please share your query and folder structure so that I can review.

Avatar

Level 4

I could figure out that was an issue with missing content index and too many subnodes.

Avatar

Level 4

By the way: Your screenshot from querybuilder debug has a tiny difference to mine. On my AEM instance there is a dropdown field right from checkbox "Extract facets" with three available options (Default, Computed, Oak). Could it be the reason why your query does not work on my instance?

Avatar

Community Advisor

I am using AEM 6.5.11. Please do share the path value in your query.