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:
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
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
Views
Replies
Total Likes
Do you happen to have an example for resulting all the published page without any of the the node name (node exists) on it? In my case it is none of the following nodes:
jcr:content/article-content
jcr:content/generic-content
Views
Replies
Total Likes
It is not possible to check node name of deeper relative nodes. Please use SQL2 queries or create custom predicate.
SQL2 Example
SELECT parent.* FROM [cq:Page] AS parent
INNER JOIN [nt:unstructured] AS child ON ISCHILDNODE(child,parent)
WHERE ISDESCENDANTNODE(parent, '/content/myproj') AND parent.[jcr:content/cq:lastReplicated] IS NOT NULL AND parent.[jcr:content/cq:lastReplicationAction] = 'Activate'
AND not(name(child) = 'article-content' OR name(child) = 'generic-content')
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.
How would I be able to achieve it without ACS Commons support? I do see link on the suggestion without the ACS commons on previous comment by could you go in more detail with example if you have it please?
Views
Replies
Total Likes
If you cannot install ACS Commons, you can simply copy the NodeExists QueryBuilder Predicate class into your repository, which does not have any dependencies on any ACS Commons item.
Views
Replies
Total Likes
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
Views
Replies
Total Likes
I have tried this and it doesn't work. It gives all the published content results as the way with the query without nodeExists:
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
Views
Replies
Total Likes
Views
Likes
Replies