Content Fragment Search using GraphQL | Community
Skip to main content
Level 2
September 26, 2025
Solved

Content Fragment Search using GraphQL

  • September 26, 2025
  • 1 reply
  • 284 views

I have a content Fragment with these fields
Title, Page Title, Canonical URL, Description, tags

I am using AEM AMS 6.5 setup. I need to create a GraphQL query for searching a word, say "Service" in multiple fields
example: serach word might be present in either of above mentioned CF fields.
I heard, there is AMS limitation that we cannot use OR or in statmeents. Where as this is possible in AEMaaCS. Also, I want to search the word in tags. But CF stores tag path. Actual Tag title is present in /content/cq:tags So, using GraphQL query, is it possible to search the word to Tag title?

 

query SearchContent($searchTerm: String!, $limit: Int = 10) { myModelName( filter: { title: { _expressions: [ { _operator: CONTAINS, value: $searchTerm } ] } OR description: { _expressions: [ { _operator: CONTAINS, value: $searchTerm } ] } _path: { _expressions: [ { _operator: STARTS_WITH, value: "/content/dam/abcd" } ] } } limit: $limit ) { items { description title } } }

 cc @arunpatidar @shashi_mulugu  @raja_reddy  @saravanan_dharmaraj  @sureshdhulipudi 

Thanks in advacne

Best answer by giuseppebaglio

hi @maheshagu,

GraphQL filters from different fields are effectively ANDed and there is no native cross‑field OR/IN; AEMaaCS adds OR within a single field’s expressions, but not a general OR across multiple fields.

When it comes to GraphQL filters on _tags, these filters utilize tag IDs (namespace/path). Therefore, searching using tag titles (jcr:title) is not supported directly.

If tags are stored on the Content Fragment itself, you can achieve your desired functionality as follows:

query { cityList( filter: {_tags: {_expressions: [{value: "tourism:city-break", _operator: CONTAINS}]}} ){ items { name, _tags } } }

If the tags are part of the Content Fragment Metadata, you can also implement it in this way:

query { adventureList { items { _path, _metadata { stringArrayMetadata { name, value } } } } }

 

1 reply

giuseppebaglio
giuseppebaglioAccepted solution
Level 10
September 26, 2025

hi @maheshagu,

GraphQL filters from different fields are effectively ANDed and there is no native cross‑field OR/IN; AEMaaCS adds OR within a single field’s expressions, but not a general OR across multiple fields.

When it comes to GraphQL filters on _tags, these filters utilize tag IDs (namespace/path). Therefore, searching using tag titles (jcr:title) is not supported directly.

If tags are stored on the Content Fragment itself, you can achieve your desired functionality as follows:

query { cityList( filter: {_tags: {_expressions: [{value: "tourism:city-break", _operator: CONTAINS}]}} ){ items { name, _tags } } }

If the tags are part of the Content Fragment Metadata, you can also implement it in this way:

query { adventureList { items { _path, _metadata { stringArrayMetadata { name, value } } } } }