Query Builder CheatSheet

Published
Modified
Query Builder offers an easy way of querying the content repository of AEM. The API is built using the JCR API. AEM includes a Query Debugger tool that allows you to execute search queries on the JCR (Java Content Repository). Utilize this tool to perform a dry run of the AEM queries, optimize them, and then implement them into your code.
The following queries return ten results (or to be precise, a maximum of ten), while also indicating the total number of available hits. Running the same query with the parameter p.limit=-1 retrieves all results, which could be a large number depending on your instance.
Pages within a Content Node
path = /content/aem-demo/de type = cq:Page
Page Name contains Specific Word
path = /content/aem-demo/de type = cq:Page nodename = *product*
Total Components within a Page
path = /content/aem-demo/de/de/jcr:content property = sling:resourceType property.operation = like property.value = %aem-demo/components% p.guessTotal = true
Search by Multiple Properties
path = /content/aem-demo/de 1_property = sling:resourceType 1_property.value = aem-demo/components/container 2_property = layout 2_property.value = simple
Search by Multiple Property Values
path = /content/aem-demo/de 1_property = sling:resourceType 1_property.value = aem-demo/components/container 2_property = layout 2_property.1_value = simple 2_property.2_value = responsiveGrid
Search under Multiple Paths
group.p.or = true group.1_path = /content/aem-demo/de group.2_path = /content/aem-demo/it 1_property = sling:resourceType 1_property.value = aem-demo/components/container
Return Selective Properties
path = /content/aem-demo/de type = cq:Page p.hits = selective p.properties = jcr:path jcr:content/jcr:title jcr:content/sling:alias
Assets within a Folder
path = /content/dam/aem-demo/de type = dam:Asset