Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Can you use Query Builder to return related assets?

Avatar

Level 2

In AEM you are able to use the "relate" function e.g. source, derived and others to associate files in AEM Assets. My question is are you able to use the query builder to target and return a list of related assets?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Try below queries

 

1) path=/content/dam
    1_property=jcr:content/related/derived/sling:members/@sling:resources
    1_property.value=/content/dam%
    1_property.operation=like
     p.limit=-1


2) type=dam:Asset
    p.hits=selective
   1_property=jcr:content/related/derived/sling:members/@sling:resources
   1_property.value=/content/dam%
   1_property.operation=like
    p.limit=-1

 

Screen Shot 2022-04-11 at 6.17.02 PM.png

In both the results I am getting the results. 

 

To return the json below is the link for above query

 

http://localhost:4502/bin/querybuilder.json?1_property=jcr%3acontent%2frelated%2fderived%2fsling%3am...

 

Screen Shot 2022-04-11 at 6.19.28 PM.png

In order to return results in desired format, you can write a servlet which will process the output of query builder and add the response to required format.

View solution in original post

3 Replies

Avatar

Community Advisor

Hi,

 

Yes, the related assets are added to related node under jcr:content

 

We can retrieve all the nodes related assets available under the path

 

{assets}/jcr:content/related/derived/sling:members

Avatar

Level 2

Am I able to use this as part of querying other properties?

Here is an example:

type=dam:Asset

p.hits=selective

p.limit=-1

p.properties=jcr:content/metadata/dc:title jcr:content/metadata/dc:description jcr:content/related/derived/sling:members

 

When I add your recommendation to my query it comes back in the JSON but is blank even when there are relationships made with the assets main folder path. What I was hoping is that it would return paths for related assets. The use case is I'm using the "Others" related option to associate Videos with their VTT files and would like to show that relationship in the JSON query with some other metadata I need to be shown. 

},
related: { }

}

Avatar

Correct answer by
Community Advisor

Try below queries

 

1) path=/content/dam
    1_property=jcr:content/related/derived/sling:members/@sling:resources
    1_property.value=/content/dam%
    1_property.operation=like
     p.limit=-1


2) type=dam:Asset
    p.hits=selective
   1_property=jcr:content/related/derived/sling:members/@sling:resources
   1_property.value=/content/dam%
   1_property.operation=like
    p.limit=-1

 

Screen Shot 2022-04-11 at 6.17.02 PM.png

In both the results I am getting the results. 

 

To return the json below is the link for above query

 

http://localhost:4502/bin/querybuilder.json?1_property=jcr%3acontent%2frelated%2fderived%2fsling%3am...

 

Screen Shot 2022-04-11 at 6.19.28 PM.png

In order to return results in desired format, you can write a servlet which will process the output of query builder and add the response to required format.