Query Builder API: Retrieve Images Without a specific tag | Community
Skip to main content
serenapitotti
Level 2
October 22, 2024
Solved

Query Builder API: Retrieve Images Without a specific tag

  • October 22, 2024
  • 4 replies
  • 826 views

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.

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 tushaar_srivastava

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

4 replies

EstebanBustamante
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
October 22, 2024

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-and-indexing-best-practices

 

Here are some resources for querybuilder:

 

https://experienceleague.adobe.com/en/docs/experience-manager-65/content/implementing/developing/platform/query-builder/querybuilder-api

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

 

Hope this helps

Esteban Bustamante
serenapitotti
Level 2
October 22, 2024

Ciao! Unfortunately it doesn't work.

tushaar_srivastava
tushaar_srivastavaAccepted solution
Level 6
October 22, 2024

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
MukeshYadav_
Community Advisor
Community Advisor
October 22, 2024

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 

kautuk_sahni
Community Manager
Community Manager
November 5, 2024

@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