How to exclude immidiate child nodes in AEM query Builder ? | Community
Skip to main content
touseefk2181136
Level 3
July 25, 2024
Solved

How to exclude immidiate child nodes in AEM query Builder ?

  • July 25, 2024
  • 4 replies
  • 938 views
I have following query in aem to use in query builder api
 
type=nt:unstructured
path=/content/data
p.limit = -1
 
it returns resultset like

/content/data/offers, (crxde, html, json)
/content/data/offers/ec3e6681-5c2b-433b-8797-6a4dbe88e0d7, (crxde, html, json)
/content/data/offers/0340d857-e7dc-4074-90a1-2f278e090a93, (crxde, html, json)
/content/data/promotions, (crxde, html, json)
/content/data/promotions/ec3e6681-5c2b-433b-8797-6a4dbe88e0d7, (crxde, html, json)
/content/data/promotions/0340d857-e7dc-4074-90a1-2f278e090a93, (crxde, html, json
 
I don't want following root node in this resultset. Means I want to exclude this immediate child nodes and want to include descendent only.

/content/data/storeoffers, (crxde, html, json)
/content/data/promotions, (crxde, html, json)
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Ravi_Pampana

Try below with nodename exclusion filter

 

type: nt:unstructured,

path: /content/data,

1_property: jcr:primaryType,

1_property.value: nt:unstructured,

2_property: jcr:path,

2_property.operation: not,

2_property.value: /content/data/offers,

3_property: jcr:path,

3_property.operation: not,

3_property.value: /content/data/promotions

p.limit: -1

4 replies

Ravi_Pampana
Community Advisor
Ravi_PampanaCommunity AdvisorAccepted solution
Community Advisor
July 25, 2024

Try below with nodename exclusion filter

 

type: nt:unstructured,

path: /content/data,

1_property: jcr:primaryType,

1_property.value: nt:unstructured,

2_property: jcr:path,

2_property.operation: not,

2_property.value: /content/data/offers,

3_property: jcr:path,

3_property.operation: not,

3_property.value: /content/data/promotions

p.limit: -1

Harwinder-singh
Community Advisor
Community Advisor
July 26, 2024

@touseefk2181136  You can find the query builder equivalent of this SQL2 query and that should do the trick : 

SELECT * FROM [nt:unstructured] AS s WHERE ISDESCENDANTNODE([/content/data]) AND NOT ISCHILDNODE([/content/data])

 

path.flat property might come in handy in that.

 

Otherwise, if you are ok with explictly adding exclusion paths, you can use the solution shared by @ravi_pampana 

 

arunpatidar
Community Advisor
Community Advisor
July 26, 2024

Hi @touseefk2181136 
Are these immediate child nodes (e.g., offers) different in some way from the grandchild nodes (e.g., ec3e6681-5c2b-433b-8797-6a4dbe88e0d7)? This difference could be a property, node type, or resource type. If you can identify a distinguishing criterion for the child nodes, you can use it to exclude them from the results.

Arun Patidar
kautuk_sahni
Community Manager
Community Manager
August 1, 2024

@touseefk2181136 Did you find the suggestions from users helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!

Kautuk Sahni