Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

How to find whether particular image rendition exists or not using query debugger or SQL2 query?

Avatar

Level 2

Hi All,

I want to search for image nodes which don't have particular image rendition.

For example.,

Suppose I have a path as '/content/dam/mycompany/catalog/part'.

I want to find the images which don't have product-details.png rendition under rendition folder.

Can anyone please help me to get the SQL2 query or query using AEM query debugger?

rendition.png

Thanks,

Prajakta

1 Accepted Solution

Avatar

Correct answer by
Level 5

Hi prajaktak28172563

Indeed the query I gave was an oversimplified one. It did give the results but not as refined.

To get the expected results, you don't really need to make the query as excessive as above.

Please try the query below

SELECT * FROM [dam:Asset] AS s where isdescendantnode([/content/dam/mycompany/catalog]) and s.[jcr:content/renditions/*] is not null and s.[jcr:content/renditions/product-details.png/jcr:primaryType] not like '%nt:file%'

This query basically checks if the renditions exist for an Asset AND any asset which might have the missing product-details.png rendition.

Best Regards,

Aneet

View solution in original post

7 Replies

Avatar

Community Advisor

Hi Prajakta,

You can do this with query debugger but for your requirement you need to create a custom predicate, which traverse through rendition node and check for product-detail.png

refer Is there way to know nodes without jcr:content node?

Thanks

Arun



Arun Patidar

Avatar

Level 5

Hello prajaktak28172563

You can simply execute a query like below to get your results

SELECT * FROM [nt:file] AS s where isdescendantnode([/content/dam/mycompany/catalog/part]) and s.[jcr:path] NOT LIKE '%product-details.png%'

This query would automatically consider only renditions as nt:file is the nodetype being used.

I hope this helps.

Regards,

Aneet

Avatar

Level 10

Above query should work! Let us know if it didnt..

Avatar

Level 2

Hi aneeta45259594 and bsloki,

I tried the query given by you but it's not returning any results.

My requirement is to find the image nodes which don't have product-details.png image rendition.

The logic in your query is saying to return all the renditions other than product-details.png which will not give the correct results.

Suppose one of the renditions folder has this rendition. Due to the above query, all the renditions other than product-details.png under that folder will be there in result which is not the requirement.

Thanks,

Prajakta

Avatar

Level 2

Hi All,

I tried with the below query

select par.[jcr:path] from [nt:folder] As par WHERE ISDESCENDANTNODE(par, "/content/dam/mycompany/catalog/part/120/051/591") AND par.[jcr:path] not in

(select parent.[jcr:path] from [nt:folder] As parent Inner Join [nt:file] AS child ON ISCHILDNODE(child, parent)

WHERE ISDESCENDANTNODE(parent, "/content/dam/mycompany/catalog/part/120/051/591")

AND parent.[jcr:path] like "%jcr:content/renditions" AND child.[jcr:path] like "%product-details.png")

and got the error as

imagerendition.png

Thanks,

Prajakta

Avatar

Correct answer by
Level 5

Hi prajaktak28172563

Indeed the query I gave was an oversimplified one. It did give the results but not as refined.

To get the expected results, you don't really need to make the query as excessive as above.

Please try the query below

SELECT * FROM [dam:Asset] AS s where isdescendantnode([/content/dam/mycompany/catalog]) and s.[jcr:content/renditions/*] is not null and s.[jcr:content/renditions/product-details.png/jcr:primaryType] not like '%nt:file%'

This query basically checks if the renditions exist for an Asset AND any asset which might have the missing product-details.png rendition.

Best Regards,

Aneet

Avatar

Level 2

Hi aneeta45259594,

Thanks for your help. It worked for me.