Expand my Community achievements bar.

Querybuilder Query to list pages with no specific node and is in published state

Avatar

Level 3

Hi,

 

I was working on the querybuilder (/libs/cq/search/content/querydebug.html) to find the published cq:page without the node name for "article-content" and "generic-content".

I have tried creating query however was not able to execute it properly.

 

Query: (Not Working)

 

path=/content
type=cq:Page
group.p.and=true

# Group 1: Check if the page has been replicated and activated
group.1_p.and=true
group.1_1_property=jcr:content/cq:lastReplicated
group.1_1_property.operation=exists
group.1_2_property=jcr:content/cq:lastReplicationAction
group.1_2_property.value=Activate

# Group 2: Ensure article-content and generic-content do not exist
group.2_p.and=true
group.2_1_property=jcr:content/article-content
group.2_1_property.operation=not
group.2_2_property=jcr:content/generic-content
group.2_2_property.operation=not

p.limit=-1

 

Note: On executing the Group 1 separately works fine and results the pages which are published:

 

Working Code for Published Pages:

 

path=/content
type=cq:Page
group.p.and=true
group.1_property=jcr:content/cq:lastReplicated
group.1_property.operation=exists
group.2_property=jcr:content/cq:lastReplicationAction
group.2_property.value=Activate
p.limit=-1

Example of the page that should be excluded from results:

BinaryAlchemy11_0-1742415475598.png

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

3 Replies

Avatar

Community Advisor

Hi @BinaryAlchemy11 

In Group2 you are searching for properties rather than nodename.

Please check below for nodename predicate

https://medium.com/@manumathew28.94/query-builder-aem-5869a1850c85 

Example

type=dam:Asset
group.p.or=true
group.1_group.1_group.p.or=true
group.2_group.1_group.p.or=true
group.1_group.path=/content/dam/we-retail/en/features
group.1_group.1_group.1_nodename=cart.png
group.1_group.1_group.2_nodename=tracking.png
group.2_group.1_group.p.or=true
group.2_group.path=/content/dam/we-retail/en/features
group.2_group.1_group.1_nodename=cart.png
group.2_group.1_group.2_nodename=tracking.png
p.limit=-1

 



Arun Patidar

Avatar

Level 6

Hi by leveraging NodeExists QueryBuilder Predicate you can update the query like this

path=/content/project
type=cq:Page
1_property=jcr:content/cq:lastReplicationAction
1_property.exists=true
2_property=jcr:content/cq:lastReplicated
2_property.exists=true
nodeExists.1_notexists=jcr:content/article-content
nodeExists.2_notexists=jcr:content/generic-content

If ACS Commons is out of the discussion, you can look at the suggestion here by @arunpatidar to leverage a custom predicate.

Avatar

Community Advisor

Hi @BinaryAlchemy11 ,
Please try below:

path=/content
type=cq:Page
p.limit=-1
1_property=jcr:content/cq:lastReplicated
1_property.exists=true
2_property=jcr:content/cq:lastReplicationAction
2_property.value=Activate

# Exclude pages having jcr:content/article-content node
nodeExists.1_notexists=jcr:content/article-content

# Exclude pages having jcr:content/generic-content node
nodeExists.2_notexists=jcr:content/generic-content

Explanation:

     - path=/content → Search under /content.
     - type=cq:Page → Search only cq:Page nodes.
     - lastReplicated & lastReplicationAction → Ensures the page is published.
     - nodeExists.notexists → Ensures the nodes do NOT exist (correct way to filter nodes, not properties).

Your Original Query Issue:
You used:

group.2_1_property=jcr:content/article-content
group.2_1_property.operation=not

This checks for property absence, but you want to check for node absence. That’s why it failed.

How It Works Internally:

QueryBuilder’s nodeExists maps to JCR XPath check for node existence.
This is more performant and precise for structural checks (like nodes), compared to property checks.

Regards,
Amit