SQL2 JCR Queries in AEM
JCR SQL2 Queries
Querybuilder -
A tool developed by Adobe for writing simple and efficient queries in AEM. It contains predicates in simple key-value form. It relies on Oak indexes for performance optimizations.
URL : http://localhost:4502/libs/cq/search/content/querydebug.html
Below is the way, how conversion happens
1. Queries are converted into XPath by Query Engine
2. XPath is comverted into JCR SQL2 queries.
3. JCR SQL2 is executed by query engine.
It has 3 parts
Predicate
Parameter
Value
List of standard Predicates provided by AEM
- path : takes a value as a content path.
- path.self :
path.self=true, searches the subtress including the main node.
path.self=false, searches only main node. - path.exact :
path.exact=true, exact path is matched.
path.exact=false, all descendents are included. - path.flat :
path.flat=true, searches only direct children
path.flat=false - type : defines a particular node type to be searched e.g. cq:Page, dam:Asset etc)
- property : a specific JCR property name.
- property.value : a value that needs to be searched.
multiple properties can be used by postfixing a number serially
1_property.value=abc - property.depth : the number of additional levels to be searched only.
- property.and : to enable the AND operation while searching with multiple properties.
Default operation is OR i.e. value of the property.and is false when not specified. - property.opearation : specify other logical operation like equals, unequals, like, not , exists
example.
path=/content/mysite
1_property=jcr:content/cq:template
1_property.value=/apps/mysite/components/template/myTemplate
2_property=jcr:content/jcr:title
2_property.value=homepage
- fulltext : for fulltext search.
- fulltext.relPath : to specify the relative path to search the given string in.
e.g. fulltext:relPath=jcr:content/@cq:tags - group : to create logical grouping conditions.
example
fulltext=searchtext
group.p.or=true
group.1_group.path=/content/mysite
group.1_group.type=cq:Page
group.2_group.path=/content/myforms
group.2_group.type=dam:Asset - orderBy : to sort the results set obtained.
e.g. orderBy=@jcr:score
orderBy=cq:lastModified - orderBy.sort : define sorting way for the search results.
e.g. orderBy.desc=true OR orderBy.sort=desc
orderBy.asc=true OR orderBy.sort=asc - orderBy.case : case sensitive search enablment
e.g. orderBy.case=ignore - p.hits : to return all properties of a node
e.g. p.hits=full
OR
p.hits=selective
p.properties=sling:resourceType jcr:title cq:lastModified - p.facets : to search facets based search for the assigned query.
- p.guessTotal : return the appropriate number of results.
- p.offset : used with p.guessTotal, to define the start of index.
- p.limit : defines the page size.
Examples
- Get all assets inside a folder
path=/content/dam/<root-folder>
type=dam:Asset
p.limit=1 - Finding all CF with CF Model
type=dam:Asset
path=/content/dam/CFpath
boolproperty=jcr:content/contentFragment
boolproperty.value=true
property=jcr:content/data/cq:model
property.value=/conf/CFpath/settings/dam/cfm/models/model1 - Searching a pages with specific tags
type=cq:Page
tagid=marketing:interest/product
tagid.property=jcr:content/cq:tags - Searching pages with specific templates
path=<page-root-path>
type=cq:Page
property=jcr:content/cq:template
property.value=/apps/rc/templates/<template>
p.limit=-1
No comments:
Post a Comment