AEM SQL2 query to get couple of properties on multiple nodes | Community
Skip to main content
kalyan_chakrav1
Level 2
Jun 20, 2019 2:49 AM UTC
Solved

AEM SQL2 query to get couple of properties on multiple nodes

Hi,

As a requirement i need to read the tags from the page. On the page we have authored multiple components, so we need to read the couple of properties which are tags on the page and the components which we authored on the page. Could you please help on the SQL2 query/XPath query.

Thanks & Regards,

Kalyan

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
arunpatidar
arunpatidarAccepted solution
New Participant
Jun 25, 2019 12:15 AM UTC

Hi,

Please find XPath Query to find node if tag exists. further, you can get the path and read the properties using ValueMap or node API

(/jcr:root/content/we-retail//element(*, cq:PageContent)

[

(@cq:tags)
] | /jcr:root/content/we-retail//element(*, nt:unstructured)[(@cq:tags)])
order by @jcr:score descending

Arun Patidar

4 replies

arunpatidar
arunpatidarAccepted solution
New Participant
Jun 25, 2019 12:15 AM UTC

Hi,

Please find XPath Query to find node if tag exists. further, you can get the path and read the properties using ValueMap or node API

(/jcr:root/content/we-retail//element(*, cq:PageContent)

[

(@cq:tags)
] | /jcr:root/content/we-retail//element(*, nt:unstructured)[(@cq:tags)])
order by @jcr:score descending

Translate
Arun Patidar
kalyan_chakrav1
Level 2
Jun 24, 2019 3:38 AM UTC

Hi,

I need one property on cq;PageContent and other property on its childnode which is nt;unstructured type. Could you please help me on the SQL2 query.

Thanks & Regards,

Kalyan

Translate
Employee
Jun 20, 2019 5:06 PM UTC

All Pages under /content that have cq:tags set (eg not null)

select * from [cq:Page] as page where page.[jcr:content/cq:tags] is not null and ISDESCENDANTNODE([/content])

Translate
Employee
Jun 20, 2019 3:15 PM UTC

The JCR Query Cheat Sheet can help you. It includes useful samples: https://wiki.magnolia-cms.com/display/WIKI/JCR+Query+Cheat+Sheet

Translate