5. JCR Query Cheat Sheet

Common Node Types

  • mgnl:page: Represents website pages
  • mgnl:content: Generic content nodes.
  • mgnl:user: User data nodes.
  • mgnl:asset: Images, documents, and other media
  • mgnl:template: Represents templates for pages or components
  • mgnl:workflow: Represents workflow items or tasks
  • mgnl:configuration: Accessing Magnolia configuration

Arithmetic Functions

 +, -, *, /

Comparison Functions

=, !=, >, <, >=, <=

Logical Functions

AND, OR, NOT

Node Functions

  • ISDESCENDANTNODE()
    Checks if a node is a descendant of another node.
  • ISCHILDNODE()
    Checks if a node is a child of another node.

String Functions

  • LOWER() 
    Converts a string to lowercase
  • CONTAINS()
    Checks if a string contains a specified substring.
  • UPPER()
    Converts a string to uppercase
  • LIKE()
    Checks whether a character string contains a specific pattern or substring

Selecting Properties

  • Select specific properties
    SELECT title, author FROM [mgnl:content]
  • Select all properties
    SELECT * FROM [mgnl:content]

Full-Text Search

  • CONTAINS(propertyName, 'text')
    Finds nodes where propertyName contains 'text'
  • propertyName LIKE('tmp_%')
    Selects nodes beginning with tmp_

Filtering Results

  • Path Condition
    WHERE ISDESCENDANTNODE([path]) selects nodes under a specific path.
  • Property Condition
    WHERE propertyName = 'value' selects nodes where a property matches a specific value.

Selecting Date and Time

  • WHERE [mgnl:lastActivated] <= CAST("2024-01-01T00:00:00.000Z" AS DATE)