GraphQL filter by "jcr:content/metadata/cq:tags" | Community
Skip to main content
btaymaz1
Level 2
September 16, 2022
Solved

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

  • September 16, 2022
  • 2 replies
  • 1240 views

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

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 Saravanan_Dharmaraj

Hope you checked this sample queries list  https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/headless/graphql-api/sample-queries.html?lang=en 

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
        }
        
      }

2 replies

Sachin_Arora_
Community Advisor
Community Advisor
September 18, 2022

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

 

Saravanan_Dharmaraj
Community Advisor
Saravanan_DharmarajCommunity AdvisorAccepted solution
Community Advisor
September 18, 2022

Hope you checked this sample queries list  https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/headless/graphql-api/sample-queries.html?lang=en 

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
        }
        
      }