Jcr sql 2 query get results of containing page along with searched asset(s) metadata | Adobe Higher Education
Skip to main content
Level 2
January 25, 2022
Répondu

Jcr sql 2 query get results of containing page along with searched asset(s) metadata

In acs commons we have reference report which will output the path and containing page of the given asset path or all the assets in the given folder path.

Now we have a scenario to write a query to render the containing page as well  the asset details

Example: path to be searched - /content/dam/we-retail/us/abc

We need the following deatils in output as

/content/dam/we-retail/us/abc/1.png  and its asset metadata along with containing page

/content/we-retail/us/en/men

/content/dam/we-retail/us/abc/2.png  and its asset metadata along with containing page

/content/we-retail/us/en/women...

 

 

Ce sujet a été fermé aux réponses.
Meilleure réponse par joerghoh

If you want to search pages, use the correct node type:

 

SELECT * FROM [cq:Page] AS s WHERE ISDESCENDANTNODE(s, "/content/sample") AND CONTAINS(s.*, '"/content/dam/z/system/archetypes/placeholder/placeholder.jpg"')

 

It will use the smaller /oak:index/cqPageLucene index instead of the huge /oak:index/lucene index, and that will give you a better performance. But of course you just the page as a result, not the individual component.

1 commentaire

Himanshu_Singhal
Community Advisor
Community Advisor
January 25, 2022

Not sure if I've understood it correctly. Do you want a query to get result of let's say to get all the page nodes where asset is used?
If so, you can use such queries.

SELECT * FROM [nt:base] AS s WHERE ISDESCENDANTNODE(s, "/content/sample") AND CONTAINS(s.*, '"/content/dam/z/system/archetypes/placeholder/placeholder.jpg"')

If your question is about getting both the pages as well as asset metadata details as part of same query, IMO, I don't think it's possible using JCR2 query. 
Correct me if I've it wrong!

joerghoh
Adobe Employee
joerghohAdobe EmployeeRéponse
Adobe Employee
January 25, 2022

If you want to search pages, use the correct node type:

 

SELECT * FROM [cq:Page] AS s WHERE ISDESCENDANTNODE(s, "/content/sample") AND CONTAINS(s.*, '"/content/dam/z/system/archetypes/placeholder/placeholder.jpg"')

 

It will use the smaller /oak:index/cqPageLucene index instead of the huge /oak:index/lucene index, and that will give you a better performance. But of course you just the page as a result, not the individual component.