Expand my Community achievements bar.

ACS Commons Reports: Reference report: Querying and Date Comparison

Avatar

Level 2

I'm working on creating a reference report using the ACS Commons Reports tool in AEM.

The goal of this report is to allow users to enter an asset path and generate a list of pages where the asset is used. The report includes columns such as the containing page, modified date, and replicated date.

However, I've encountered an issue where the queries (like "contains" or "fulltext") do not search through grandchild nodes, potentially leading to incomplete results. Additionally, I need to ensure that the Page's modified date is more recent than the replicated date.

 

Could you provide guidance on how to write effective queries for this purpose or suggest alternative approaches to achieve accurate and comprehensive results?

 

Thank you

6 Replies

Avatar

Level 2

Was able to do 50% of the above requirement.

SELECT parent.*
FROM [cq:Page] AS parent
INNER JOIN [nt:base] AS child
ON ISDESCENDANTNODE(child, parent)
WHERE ISDESCENDANTNODE(parent, '/content/project/page-path')
AND (CONTAINS(child.*, '/content/dam/project/asset-path'))

Adding query for date will be pretty much helpful....

OR you can also share as an x-path

Avatar

Community Advisor

Hi, 

I think the easiest way to achieve what you need is to use the Java API AssetReferenceSearch https://developer.adobe.com/experience-manager/reference-materials/6-4/javadoc/com/day/cq/dam/common... where you can get a list of pages and then you can extract from them any other information you need. 

 

Please check this thread, where also the query option is discussed: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-find-the-list-of-al... 

 

Hope this helps.



Esteban Bustamante

Avatar

Level 2

Thank you for your response, @EstebanBustamante.

We are leveraging the existing features provided by ACS Commons Reports, such as returning assets with simple queries and adding columns via components. Therefore, we don't want to create a new feature from scratch.

I have observed that in JCR-SQL2, it's not possible to compare dynamic operands like 'lastModified' and 'lastReplicated'. However, since QueryBuilder allows for date comparisons, I was hoping to modify the SQL2 query to suit QueryBuilder's syntax and capabilities. Could you help adjust the above JCR SQL 2 query accordingly to leverage QueryBuilder's ability to compare dates?

 

Avatar

Level 2

In JCR-SQL2, comparing dates for this case directly is not possible because `cq:lastModified` and `cq:lastReplicated` are dynamic operands.

 

However, the QueryBuilder API allows date comparisons using the `daterange` keyword, as documented here: Query builder cheatsheet

 

For reference searches, we rely on the `fulltext` or 'contains' property, but it has a limitation: it can only search up to five levels deep within the node hierarchy, and some assets are nested beyond that level, but this case won't exist all the time.

 

While the JCR-SQL2 query I mentioned does return the expected results, its execution time is significantly high, which can potentially impact system performance. Long-running queries like this can create additional load on the system, leading to performance degradation.

Feel free to correct this statement....much appreciated.

Avatar

Administrator

@bona Did you find the suggestions from users helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!



Kautuk Sahni