Query Builder | Community
Skip to main content
Level 6
May 4, 2022

Query Builder

  • May 4, 2022
  • 1 reply
  • 1919 views

Can someone help me with this query.

I am trying to find all the nodes under content that have a sling:resourceType=

components/content/home/homeHeroTeaser 

I wrote the above as:

 

String query = '''
SELECT * FROM [nt:base] AS n
WHERE ISDESCENDANTNODE([/content])
AND n.[sling:resourceType]='components/content/home/homeHeroTeaser'
'''

 In addition I would like add to this query a check that a node has a property link that has a value. How do I do that?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

DEBAL_DAS
New Member
May 4, 2022

I have added Teaser component in we.retail page here -

Author's entries -

 

Persisted data in CRXDE -

Query builder query has given below -

path=/content/we-retail
type=nt:unstructured
1_property=sling:resourceType
1_property.value=weretail/components/content/teaser
2_property=linkURL
2_property.operation=exists
p.limit=-1

 

Hope this will help you. But I would request you to check the node structure of homeHeroTeaser component in CRXDE then we can decide whether we should add following check in "a node has a property link that has a value" in query or code.

 

Debal Das, Senior AEM Consultant
anasusticAuthor
Level 6
May 4, 2022
1_property=sling:resourceType
1_property.value=weretail/components/content/teaser
2_property=linkURL
2_property.operation=exists
p.limit=-1

Hi. Thanks so much for creating the test content and writing the query. Can you please explain the lines above (ie. 1_property, 1_property.value...)? 

DEBAL_DAS
New Member
May 4, 2022

My requirement is to find all the nodes under /content that have  sling:resourceType=weretail/components/content/teaser and also check that a node has a property linkURL that has a value, it means I need to consider two different properties sling:resourceType and linkURL here.

When using the property predicate multiple times, then I have to add the number prefixes again as shown below -

type=cq:Page
1_property=jcr:content/cq:template
1_property.value=/apps/geometrixx/templates/homepage
2_property=jcr:content/jcr:title
2_property.value=English
Debal Das, Senior AEM Consultant