0
votes

I wish to build a sql2 jcr query to find all pages under /content that contains this component, e.g /apps/platform/aem-core/components/content/form/form

I read https://wiki.magnolia-cms.com/display/WIKI/JCR+Query+Cheat+Sheet and tried something like below

My current attempt is something like SELECT * from [cq:Page] AS t WHERE t.contains('/apps/platform/aem-core/components/content/form/form')

But it won't work. Please suggest me a example to find all pages contains this component. Thanks

1
if you are on AEM you may want to use QueryBuilder - helpx.adobe.com/experience-manager/6-4/sites/developing/using/… api. It provides additional capabilities and ease of use by providing predicates for commonly used searches.awd

1 Answers

0
votes

As @awd has mentioned in the comments, QueryBuilder provides better capabilities.

SQL2 however is not that bad, especially for someone with an inclination towards RDBMS !

The below query should fetch all the page paths using the component resourceType.

SELECT * FROM [cq:PageContent] AS s WHERE ISDESCENDANTNODE(s,'/content') AND CONTAINS(s.[sling:resourceType], 'foundation/components/text')

You've got to use square brackets for properties with namespaces in them, for e.g: cq:template, sling:resourceType, etc