How to find whether particular image rendition exists or not using query debugger or SQL2 query? | Community
Skip to main content
Level 2
Jun 11, 2018 1:53 PM UTC
Solved

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

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?

Thanks,

Prajakta

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
aneetaroraAccepted solution
Employee
Jun 12, 2018 8:11 PM UTC

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

7 replies

PrajaktaAuthor
Level 2
Jun 13, 2018 7:41 AM UTC

Hi aneeta45259594,

Thanks for your help. It worked for me.

Translate
aneetaroraAccepted solution
Employee
Jun 12, 2018 8:11 PM UTC

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

Translate
PrajaktaAuthor
Level 2
Jun 12, 2018 12:31 PM UTC

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

Thanks,

Prajakta

Translate
PrajaktaAuthor
Level 2
Jun 12, 2018 9:26 AM UTC

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

Translate
Lokesh_Shivalingaiah
Level 10
Jun 12, 2018 5:12 AM UTC

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

Translate
Employee
Jun 11, 2018 7:24 PM UTC

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

Translate
arunpatidar
New Participant
Jun 11, 2018 3:42 PM UTC

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

Translate
Arun Patidar