A Practical Look at AEM Query Builder

This article is a highlight of my work at Genesis10.

In my roles, I’ve had the chance to leverage the robust features of Adobe Experience Manager (AEM), including its advanced querying capabilities. Today, I’d like to take you on a journey behind the scenes, revealing how the AEM Query Builder framework has become a vital tool in my daily tasks as an AEM Product Owner, Marketing Technology Manager, and Web Marketing Program Manager.

The Essence of AEM Query Builder

At its core, the AEM Query Builder is a robust framework designed by Adobe to construct queries that are simple yet effective. These queries tap into the JCR XPath underneath and are executed by the OAK Query Engine. The beauty of this framework lies in its simplicity; queries are composed of a straightforward set of predicates in key-value form.

A Glimpse into AEM Reports, CRX, and Query Builder

In my role, I frequently utilize AEM Reports, CRX, and the Query Builder to gather data that informs feature prioritization, enhancements, and content cleanup. Editing these reports provides insights into the queries and CRX values that can be leveraged within the Query Builder.

Navigating the Query Landscape

One of the common tasks I encounter is determining the usage frequency of specific components across our site. For instance, let’s say I want to know how often [Some Site] uses the [Widget Component] in their posts. Here’s how I would approach it:

  1. Identify the desired path for the query, such as /content/my/site.
  2. Navigate to CRX and locate a page featuring the [Widget Component].
  3. Determine the component’s value and type, for example:
    • property=sling:resourceType
    • property.value=foundation/component/widget
  4. Construct the query with the identified parameters, ensuring to include operations like property.operation=equals and setting the limit with p.limit=10.

This query would yield all instances where the [Widget Component] has been utilized within [My Site] but only display the first 10 results on the page.

Enhancing Queries for Precision

To refine the search further, I could modify the query to focus solely on blog posts that incorporate the [Widget Component]. By adjusting parameters such as path, property.1_value, and p.hits, I can obtain a selective list of posts, complete with their paths, that meet the criteria.

Searching Content within an AEM Component Example

This AEM Query Debugger query searches for text-editor components within the /content/my/site path that contain the <hr> string in their content. It returns up to 10 matching nodes.

path=/content/my/site
property=sling:resourceType
property.value=foundation/component/widget/text-editor
fulltext=<hr>
p.limit=10

The Impact of AEM Query Builder

The AEM Query Builder allows me to extract meaningful data with precision and efficiency. It’s a tool to help us make informed decisions to improve our engineering efforts.

In the example of searching for horizontal rules in a text editor component, we can determine which features authors are using or not using. This helps us make informed decisions about deprecating any unnecessary elements from our components. Continuously refining components and adding features reduces tech debt and enhances the authoring experience.

Leave Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.