Tuesday, 28 March 2023

Querybuilder Queries in AEM

  

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

  1. path : takes a value as a content path.
  2. path.self :
    path.self=true, searches the subtress including the main node.
    path.self=false, searches only main node.
  3. path.exact
    path.exact=true, exact path is matched.
    path.exact=false, all descendents are included.
  4. path.flat : 
    path.flat=true, searches only direct children
    path.flat=false
  5. type : defines a particular node type to be searched e.g. cq:Page, dam:Asset etc)
  6. property : a specific JCR property name.
  7. property.value : a value that needs to be searched.
    multiple properties can be used by postfixing a number serially
    1_property.value=abc
  8. property.depth : the number of additional levels to be searched only.
  9. 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.
  10. 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
     
  11. fulltext : for fulltext search.
  12. fulltext.relPath : to specify the relative path to search the given string in.
    e.g. fulltext:relPath=jcr:content/@cq:tags
  13. 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

  14. orderBy : to sort the results set obtained.
    e.g. orderBy=@jcr:score
    orderBy=cq:lastModified
  15. 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
  16. orderBy.case : case sensitive search enablment
    e.g. orderBy.case=ignore
  17. 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
  18. p.facets : to search facets based search for the assigned query.
  19. p.guessTotal : return the appropriate number of results.
  20. p.offset : used with p.guessTotal, to define the start of index.
  21. p.limit : defines the page size.

Examples

  1. Get all assets inside a folder
    path=/content/dam/<root-folder>
    type=dam:Asset
    p.limit=1


  2. 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
  3. Searching a pages with specific tags
    type=cq:Page
    tagid=marketing:interest/product
    tagid.property=jcr:content/cq:tags
  4. 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

Dispatcher configurations in AEM - 2

 Dispatcher configuration 1. The Dispatcher configuration is stored in the dispatcher.any text file. 2. The file contains a series of single...