Is there way to know nodes without jcr:content node? | Community
Skip to main content
GK-007
Level 9
Dec 9, 2016 9:55 AM UTC
Solved

Is there way to know nodes without jcr:content node?

Hi All,

Is there any way/tool to know the JCR nodes without jcr:content?

Please help me!!!

Thanks,

Kishore

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
kautuk_sahni
kautuk_sahniAccepted solution
Employee
Dec 12, 2016 8:00 AM UTC

Hi 

Please have a look at these posts:- 

Link:-http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manager.topic.html/forum__aswh-hello_can_someon.html

// How to find nodes without specific child node? How can I find nodes without specific child node (e.g. jcr:content)?

 

Link:- http://stackoverflow.com/questions/25019693/cq-5-query-builder-to-get-list-of-pages-without-jcrcontent-node

// to get list of pages without jcr:content node

 

I hope this would help you.

~kautuk

Kautuk Sahni

17 replies

New Participant
Jul 24, 2023 10:50 AM UTC

I think the following query will work if the intention is to find the Pages.

It basically checks if the child node, jcr:content, has the property, jcr:title.
The assumption is - all jcr:content has jcr:title. If there is a jcr:content without this property, the query won't work.

 

path=/content type=cq:Page property=jcr:content/jcr:title property.operation=exists property.value=false p.limit=-1

 

Translate
New Participant
Dec 16, 2022 4:05 PM UTC

Old post but documenting it if someone stumbles across it:

It may not be possible to check directly if a node has a jcr:content node, but in many cases it may suffice to check for a certain property, like jcr:title if you are search for "Pages without a jcr:content node", for example:

 

SELECT * FROM [cq:Page] AS p WHERE ISDESCENDANTNODE([/content/mysite]) AND p.[jcr:content/jcr:title] IS NULL
Translate
Level 2
Feb 2, 2021 8:07 AM UTC

You could use the groovy console (http://localhost:4502/groovyconsole) with a simple script like:

final query = session.workspace.queryManager.createQuery("SELECT * FROM [cq:Page] AS page WHERE ISDESCENDANTNODE(page, '/content/yoursite')", "JCR-SQL2") final results = query.execute() results.nodes.each{ node -> if (!node.hasNode("jcr:content")) { println node.path + " is missing the jcr:content node" } }

 As you can see, this only searches for pages but can be changed or extended to work for dam:Asset depending on your use-case.

Translate
kautuk_sahni
Employee
Feb 3, 2021 1:39 PM UTC
Thank you for sharing solution with community.
Translate
Kautuk Sahni
arunpatidar
New Participant
Jun 8, 2018 7:42 AM UTC

Hi,

nodename doesn't support operation features only property does. So it won't work.

In this case you need to write your own predicate like Child to achieve this

OR you can create a servlet which traverse through path and find out all the Childs without jcr:content using Node API, and if you wish you can delete those nodes right away inside Servlet.

Thanks

Arun

Translate
Arun Patidar
Level 2
Jun 8, 2018 6:09 AM UTC

Hi ,

        I Had tried with this Query as well.

type=dam:Assest

path=/content/dam

nodename=jcr:content

node.operation=not

p.limit=-1

But Still I am getting the list of pages which has jcr:content in it. My ultimate aim is to skip the jcr:content  from search results is there any way to that ?

Translate
arunpatidar
New Participant
Jun 7, 2018 7:06 PM UTC

HI,

I above query child is a custom predicate , you have to create that before using. same is mentioned in Link also.

but If you want to check specific node with name you can use nodename like below:

path=/content/dam

type=dam:Assest

nodename=jcr:content

p.limit=-1

Translate
Arun Patidar
Level 2
Jun 7, 2018 6:24 PM UTC

Please help me on this.

Translate
Level 2
Jun 7, 2018 6:23 PM UTC

Hi Kautukashni,

I had tried with the below mentioned link but it is not working.

Link:- http://stackoverflow.com/questions/25019693/cq-5-query-builder-to-get-list-of-pages-withou t-jcrcontent-node

// to get list of pages without jcr:content node

And my requirment was to remove the jcr:content from the Dam Assets, Please find my Query below.

Jcr Query :

path=/content/dam

type=dam:Assest

child.name=jcr:content
child.operator=not_exists
p.limit=-1

Translate
kautuk_sahni
kautuk_sahniAccepted solution
Employee
Dec 12, 2016 8:00 AM UTC

Hi 

Please have a look at these posts:- 

Link:-http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manager.topic.html/forum__aswh-hello_can_someon.html

// How to find nodes without specific child node? How can I find nodes without specific child node (e.g. jcr:content)?

 

Link:- http://stackoverflow.com/questions/25019693/cq-5-query-builder-to-get-list-of-pages-without-jcrcontent-node

// to get list of pages without jcr:content node

 

I hope this would help you.

~kautuk

Translate
Kautuk Sahni
GK-007
GK-007Author
Level 9
Dec 10, 2016 1:42 PM UTC

I have seen it.

Wants to know if there are still any such nodes without jcr:content node in our application.

Looking for a way to know these kind of nodes.

-Kishore

Translate