Tuesday, March 13, 2018

QueryBuilder - Useful Queries

AEM provides useful tool to run dynamic queries on repository.

QueryBuilder Link- http://localhost:4502/libs/cq/search/content/querydebug.html

1. Find List of all templates template


Set Extract facets true (Enable checkbox)

path=/content/mysite/mypath
type=cq:Page
property=jcr:content/sling:resourceType
property.operation=exists // Check that property exists
p.hits=selective // you want only selected properties as defined by p.properties
p.properties=sling:resourceType  // What properties you want in facets, multiples separated by space

2. Find list of pages of a particular template


path=/content/mysite/mypath
type=cq:Page
property=jcr:content/sling:resourceType
property.value=my-site/components/page/somepage
p.limit=-1 //All results
p.guessTotal=true // Makes search faster

3. Check asset types in a DAM path


Set Extract facets true (Enable checkbox)

path=/content/dam/myapp
type=dam:Asset
property=jcr:content/metadata/dam:Fileformat // OR use dc:format for better results
property.operation=exists
p.hits=selective by p.properties
p.properties=jcr:content/metadata/dam:Fileformat // OR use dc:format for better results

4. Find list of all components used in site


path=/content/my-site
type=nt:unstructured
property=sling:resourceType
property.operation=exists
p.hits=selective by p.properties
p.properties=sling:resourceType

Notes-

property.operation : “equals” for exact match (default), “unequals” for unequality comparison, “like” for using the jcr:like xpath function , “not” for no match , (value param will be ignored) or “exists” for existence match .(value can be true – property must exist)

5. Property Does not Exist


type=dam:Asset
path=/content/dam/my/project
1_property=jcr:content/metadata/dc:format
1_property.value=application/zip
2_property=jcr:content/metadata/custom
2_property.value=false
2_property.operation=exists
p.limit=-1

6. Find all nodes created after a particular time or with in a specified interval


path=/content/dam/my/project
type=dam:Asset
property=jcr:content/metadata/dc:format
property.value=application/zip
daterange.property=jcr:created
daterange.lowerBound=2019-03-04T00:00:00.000+05:30

You can use upperBound if you want less than "<" restraint on this query to find items with in a specified time period.

No comments:

Post a Comment

CDN | Clearing Cloudflare cache

In order to clear Cloudflare cache automatically via code, follow below steps: 1. Develop Custom TransportHandler Develop a custom Trans...