Find all instances of a particular component
Find all instances of a component where a property contains some string
Find all instances of a component where some property is not empty
Find all instances of a component on active pages only
Find all instances of a component that are descendants of a particular parent node name
Count pages under a particular path
Find pages that use a particular template
Find pages that were activated after a certain date
Find pages that are not active
Find pages that have never been activated and are older than some specific date
Find pages that were created within some date range
Find pages that were last modified by specific user
Find all instances of a string, excluding a particular path
Find active PDFs in the DAM
Find nodes by name
SELECT * FROM [nt:base] AS s
WHERE
ISDESCENDANTNODE([/content]) AND
s.[sling:resourceType] = 'relative/path/to/component'
SELECT * FROM [nt:base] AS s
WHERE
ISDESCENDANTNODE([/content]) AND
s.[sling:resourceType] = 'relative/path/to/component' AND
s.[property] LIKE '%string%'
SELECT * FROM [nt:base] AS s
WHERE
ISDESCENDANTNODE([/content]) AND
s.[sling:resourceType] = 'relative/path/to/component' AND
s.[property] IS NOT NULL
SELECT * FROM [cq:PageContent] AS page
INNER JOIN [nt:base] AS component ON ISDESCENDANTNODE(component, page)
WHERE
ISDESCENDANTNODE(page, [/content]) AND
page.[cq:lastReplicationAction] = 'Activate' AND
component.[sling:resourceType] = 'relative/path/to/component'
Find all instances of a component that are descendants of a particular parent node name (Type: SQL2)
SELECT * FROM [nt:base] AS parent
INNER JOIN [nt:base] AS component ON ISDESCENDANTNODE(component, parent)
WHERE
ISDESCENDANTNODE(parent, [/content]) AND
NAME(parent) = 'node-name' AND
component.[sling:resourceType] = 'relative/path/to/component'
SELECT * FROM [nt:base] AS s
WHERE
ISDESCENDANTNODE([/content]) AND
s.[jcr:primaryType] = 'cq:PageContent' AND
s.[cq:template] IS NOT NULL
SELECT * FROM [nt:base] AS s
WHERE
ISDESCENDANTNODE([/content]) AND
s.[jcr:primaryType] = 'cq:PageContent' AND
s.[cq:template] = '/path/to/template'
SELECT * FROM [nt:base] AS s
WHERE
ISDESCENDANTNODE([/content]) AND
s.[jcr:primaryType] = 'cq:PageContent' AND
s.[cq:lastReplicationAction] = 'Activate' AND
s.[cq:lastReplicated] > '2022-02-25T00:00:00.000-05:00'
This query will return pages where lastReplicationAction is either blank or doesn't equal to "Activate".
SELECT * FROM [nt:base] AS s
WHERE
ISDESCENDANTNODE([/content]) AND
s.[jcr:primaryType] = 'cq:PageContent' AND
s.[cq:template] IS NOT NULL AND
(
s.[cq:lastReplicationAction] <> 'Activate' OR
s.[cq:lastReplicationAction] IS NULL
)
This provides a good way to find unused pages to purge.
SELECT * FROM [nt:base] AS s
WHERE
ISDESCENDANTNODE([/content]) AND
s.[jcr:primaryType] = 'cq:PageContent' AND
s.[cq:template] IS NOT NULL AND
s.[cq:lastReplicationAction] IS NULL AND
s.[cq:lastModified] < '2020-01-00T00:00:00.000-05:00'
SELECT * FROM [nt:base] AS s
WHERE
ISDESCENDANTNODE([/content]) AND
s.[jcr:primaryType] = 'cq:PageContent' AND
s.[cq:template] = '/path/to/template' AND
s.[jcr:created] > '2021-01-01T00:00:00.000-05:00' AND
s.[jcr:created] < '2022-01-01T00:00:00.000-05:00'
SELECT * FROM [nt:base] AS s
WHERE
ISDESCENDANTNODE([/content]) AND
s.[cq:template] IS NOT NULL AND
s.[jcr:primaryType] = 'cq:PageContent' AND
s.[cq:lastModifiedBy] = 'user'
SELECT * FROM [nt:base] AS s
WHERE
ISDESCENDANTNODE([/content]) AND
NOT ISDESCENDANTNODE([/path/to/exclude]) AND
CONTAINS(*, '"my string"')
/jcr:root/content/dam//*[
@jcr:primaryType = 'dam:AssetContent' and
@cq:lastReplicationAction = 'Activate' and
metadata@dc:format = 'application/pdf'
]
SELECT * FROM [nt:base] AS s
WHERE
ISDESCENDANTNODE([/content]) AND
NAME() = 'node-name'