Expand my Community achievements bar.

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

GraphQL filter by "jcr:content/metadata/cq:tags"

Avatar

Level 3

Is it possible to filter content fragments by "jcr:content/metadata/cq:tags" ?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hope you checked this sample queries list  https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/headless/graphql-ap... 

I don't see the way to filter out based on Metadata. You can do it with the data stored in Master node as mentioned by Sachin below. Or you can use Query Builder to read that info.

 

You can just the output with all the tags added in Metadata in the json and filter it in the front end. That stringArrayMetadata will give the tags

_metadata {
        stringMetadata {
          name,
          value
        }
        stringArrayMetadata {
          name,
          value
        }
        
      }

View solution in original post

2 Replies

Avatar

Community Advisor

Is there any reason we are looking on metadata instead of data?GraphQL works on the schema that we define in the content fragment model whereas the property you are referring is the properties of an Asset.

Whatever fields Author edits of a CF schema/model, are saved on this location : PATH_CF/jcr:content/data/master(Master CF) which can be easily filtered using below GraphQL query where category is a Tag based field.

{
  sampleCFList (filter: {
    category: {
      _expressions: [{
        value: "sample:category/category1"
      }]  
    }
  }) {
    items {
      title
      _path
    }
  }
}

To fetch CF based on tags(Asset Properties), then you can use AEM Query Builder API.

path=/content/dam
type=dam:Asset
property=jcr:content/metadata/@cq:tags
property.value=TAG_VALUE

 

Avatar

Correct answer by
Community Advisor

Hope you checked this sample queries list  https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/headless/graphql-ap... 

I don't see the way to filter out based on Metadata. You can do it with the data stored in Master node as mentioned by Sachin below. Or you can use Query Builder to read that info.

 

You can just the output with all the tags added in Metadata in the json and filter it in the front end. That stringArrayMetadata will give the tags

_metadata {
        stringMetadata {
          name,
          value
        }
        stringArrayMetadata {
          name,
          value
        }
        
      }