Expand my Community achievements bar.

SOLVED

How to exclude immidiate child nodes in AEM query Builder ?

Avatar

Level 3
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)
Topics

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

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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

View solution in original post

4 Replies

Avatar

Correct answer by
Community Advisor

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

Avatar

Community Advisor

@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 

 

Avatar

Community Advisor

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

Avatar

Administrator

@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