Expand my Community achievements bar.

Query Builder API: Retrieve Images Without a specific tag

Avatar

Level 3

I need to execute a Query Builder API (querybuilder.json) call to fetch all images that do not have the jcr:content/metadata/cq:tags property set to "region:Italy"; the images are saved on a specific path inside the Assets of Adobe Media Library

Please provide guidance on the necessary query builder syntax and any relevant API documentation.

Thanks.

5 Replies

Avatar

Community Advisor

Hi, 

Something like this should work:

path=/content/dam/yourFolder
type=dam:Asset
property=jcr:content/metadata/cq:tags
property.value=region:Italy
property.operation=not
p.limit=-1

where:

  • path: Specifies the root path where the search will be conducted.
  • type: Indicates the type of resource you're searching for (in this case, dam:Asset for images).
  • property: Refers to the property you want to check (here, jcr:content/metadata/cq:tags).
  • property.value: The value you're looking for, which is "region:Italy".
  • property.operation: Setting this to not filters out the assets with the specified tag.
  • p.limit: This specifies the number of results to return. Setting it to -1 means no limit on the number of results.

 

Be careful that query a large folder as this can cause performance issues, and make sure you follow these best practices: https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/operations/query...

 

Here are some resources for querybuilder:

 

https://experienceleague.adobe.com/en/docs/experience-manager-65/content/implementing/developing/pla...

https://hashimkhan.in/2015/12/02/query-builder/ 

 

Hope this helps



Esteban Bustamante

Avatar

Level 7

Hi @serenapitotti , please try below: 

http://localhost:4502/libs/cq/search/content/querydebug.html 

 

 

 

path=/content/dam/your-specific-path
type=dam:Asset
property=jcr:content/metadata/cq:tags
property.operation=unequals
property.value=region:Italy
p.limit=-1

 

 

 

My Anytime go to Query Builder link to go through for all possible answers:

  1. Hashim Khan https://hashimkhan.in/2015/12/02/query-builder/ 
  2. Query Builder Cheat Sheet  https://github.com/paulrohrbeck/aem-links/blob/master/querybuilder_cheatsheet.md

Avatar

Community Advisor

Hi @serenapitotti ,

Below query works fine for me, I tested few scenario.

We need to use like operator because cq:tags field is multifield, hence equals operation will fails if there are more than one tag for the asset (i.e. region:Italy tag plus some other tag as well

 

path=/content/dam/we-retail/en/people/mens
type=dam:Asset
group.property=jcr:content/metadata/cq:tags
group.property.operation=like
group.property.value=%we-retail:activity/biking%
group.p.not=true
p.limit=-1

 

Note:- It will fetch asset with empty tag (or no tag property) as well as it does not contains given tag

PS:- Kindly change the tag id  group.property.value=%we-retail:activity/biking% and path=/content/dam/we-retail/en/people/mens as per your project.

If required you may narrow down only to image asset by using grouping

Thanks 

Avatar

Administrator

@serenapitotti Did you find the suggestions 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