Find all AEM Pages with Tags with Query Builder API

The Query Builder is a great tool that allows us to search for nodes in the JCR. We often as AEM developers use this tool to build a query for us to use in the backend to build query descriptions (predicates); the set of predicates produced will call the Predicate Evaluator which knows how to handle that specific predicate for XPath, filtering, and facet extraction.

In this article, we will be sharing query examples to find all AEM pages with single-tag && multi-tags using the Query Builder Debugger tool.


1. Find all AEM pages with a single cq:tag

Find all pages under /content/we-retail,
and has the tag of we-retail:apparel/pants,
show max results.

1
2
3
4
5
path=/content/we-retail
type=cq:Page
property=jcr:content/@cq:tags
property.value=we-retail:apparel/pants
p.limit=-1

http://localhost:4502/libs/cq/search/content/querydebug.html?_charset_=UTF-8&query=path%3D%2Fcontent%2Fwe-retail%0D%0Atype%3Dcq%3APage%0D%0Aproperty%3Djcr%3Acontent%2F%40cq%3Atags%0D%0Aproperty.value%3Dwe-retail%3Aapparel%2Fpants%0D%0A%0D%0A


1. Find all AEM pages with multiple cq:tags

Find all pages under /content/we-retail, a
and
((has the tag of we-retail:apparel/pants) or
(has the tag of we-retail:apparel/pants)),
show max results.

1
2
3
4
5
6
7
8
path=/content/we-retail
type=cq:Page
group.1_property=jcr:content/@cq:tags
group.1_property.value=we-retail:apparel/pants
group.2_property=jcr:content/@cq:tags
group.2_property.value=we-retail:apparel/shirt
group.p.or=true
p.limit=-1

http://localhost:4502/libs/cq/search/content/querydebug.html?_charset_=UTF-8&query=path%3D%2Fcontent%2Fwe-retail%0D%0Atype%3Dcq%3APage%0D%0Agroup.1_property%3Djcr%3Acontent%2F%40cq%3Atags%0D%0Agroup.1_property.value%3Dwe-retail%3Aapparel%2Fpants%0D%0Agroup.2_property%3Djcr%3Acontent%2F%40cq%3Atags%0D%0Agroup.2_property.value%3Dwe-retail%3Aapparel%2Fshirt%0D%0Agroup.p.or%3Dtrue%0D%0Ap.limit%3D-1%0D%0A%0D%0A%0D%0A



Was this post helpful?

Hello, I am an enthusiastic Adobe Community Advisor and a seasoned Lead AEM Developer. I am currently serving as an AEM Technical Lead at MNPDigital.ca, bringing over a decade of extensive web engineering experience and more than eight years of practical AEM experience to the table. My goal is to give back to the AEM Full Stack Development community by sharing my wealth of knowledge with others. You can connect with me on LinkedIn.

Leave a Reply

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

Back To Top