Query with subassets | Community
Skip to main content
June 3, 2016
Solved

Query with subassets

  • June 3, 2016
  • 5 replies
  • 3548 views

Hello all,

I have a case with a bunch of pdf's and they have sub folders with various years. Within the years are pdf files.

Now on ingestion AEM creates sub assets of each page within the PDF. For my use case I need my query

to just return the pdf file path. How can I get query results that exclude the sub assets?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by kautuk_sahni

The Big Red wrote...

smacdonald2008 wrote...

Post a screenshot of the JCR with the PDF files please.

 


Attached is the screen shot of the JCR. I need to get the pdf only in my query while filtering out the subassets.

So in this case I just want query to return AVA12_1999.pdf and filter out the page#.pdf

 

Please have alook at:- http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manager.topic.html/forum__vquz-hi_sir_madamih.html

// String sql= "SELECT * FROM sling:Folder WHERE jcr:path LIKE '"+path +"/%'  AND NOT jcr:path LIKE '"+path +"/%/%'";

OR

select * from [dam:Asset] where [jcr:path] like '/content/pdf_archives/current_brands/Avantages/%' AND [jcr:path] NOT like '/content/pdf_archives/current_brands/Avantages/%/subassets%'

~kautuk


 

5 replies

kautuk_sahni
kautuk_sahniAccepted solution
Employee
June 7, 2016

The Big Red wrote...

smacdonald2008 wrote...

Post a screenshot of the JCR with the PDF files please.

 


Attached is the screen shot of the JCR. I need to get the pdf only in my query while filtering out the subassets.

So in this case I just want query to return AVA12_1999.pdf and filter out the page#.pdf

 

Please have alook at:- http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manager.topic.html/forum__vquz-hi_sir_madamih.html

// String sql= "SELECT * FROM sling:Folder WHERE jcr:path LIKE '"+path +"/%'  AND NOT jcr:path LIKE '"+path +"/%/%'";

OR

select * from [dam:Asset] where [jcr:path] like '/content/pdf_archives/current_brands/Avantages/%' AND [jcr:path] NOT like '/content/pdf_archives/current_brands/Avantages/%/subassets%'

~kautuk


 

Kautuk Sahni
Kunal_Gaba_
New Participant
June 6, 2016
You can try the following- select * from [dam:Asset] where [jcr:path] like '/content/pdf_archives/current_brands/Avantages/%' AND [jcr:path] NOT like '/content/pdf_archives/current_brands/Avantages/%/subassets%'
June 6, 2016

smacdonald2008 wrote...

Post a screenshot of the JCR with the PDF files please.

 


Attached is the screen shot of the JCR. I need to get the pdf only in my query while filtering out the subassets.

So in this case I just want query to return AVA12_1999.pdf and filter out the page#.pdf

kautuk_sahni
Employee
June 6, 2016

Hi 

Please have a look at this old Post:- http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manager.topic.html/forum__vquz-hi_sir_madamih.html

//

For this type of query - i would look at using the JCR SQL/2. You may have better results by specifying JCR SQL search criteria. See:

https://wiki.magnolia-cms.com/display/WIKI/JCR+Query+Cheat+Sheet

http://www.day.com/maven/jcr/2.0/6_Query.html.

http://www.h2database.com/jcr/grammar.html

What I like about JCR SQL is the ability is include and exclude JCR paths. For example:

 String sql= "SELECT * FROM sling:Folder WHERE jcr:path LIKE '"+path +"/%'  AND NOT jcr:path LIKE '"+path +"/%/%'";

You should be able to write methods using JCR SQL to grab all content in the tree that you specified and search through it. 

I hope this will help you.

Thanks and Regards

Kautuk Sahni

Kautuk Sahni
smacdonald2008
New Participant
June 3, 2016

Post a screenshot of the JCR with the PDF files please.