AEM Assets GraphQL tag filter returns no results despite matching tags
Adobe Experience Manager (AEM) Assets GraphQL queries may not return Content Fragments with matching tags when a multi-value tags field is treated as a scalar. To resolve the issue, use the appropriate array filter operators, target the correct tags field, and verify that the assigned tag data matches the filter.
Description description
Environment
Adobe Experience Manager (AEM) Assets (all versions)
Issue/Symptoms
- GraphQL queries filtering by the tags field return no Content Fragments even when the requested tag exists in the data.
- Querying by slug returns the expected Content Fragment and its tags.
- Adding the tags parameter causes the matching Content Fragment to no longer be returned.
Root cause
The GraphQL filter treats the multi-value tags field as a scalar, resulting in no matches. Multi-value fields require the appropriate array filter operators.
Resolution resolution
Follow the steps below to resolve the issue:
-
Confirm that the tags field in the Content Fragment model is a multi-value array rather than a scalar string.
-
Update the GraphQL filter to use
_apply: AT_LEAST_ONCEto match at least one element in the array. For example:code language-none tags: { _expressions: [ { value: "" _operator: EQUALS _apply: AT_LEAST_ONCE } ] } -
Use
_operator: EQUALSfor exact tag ID matches. Use_operator: CONTAINSonly for substring or hierarchical matching. -
If you’re using a custom tags field, ensure that the filter targets the correct field. The built-in field is
_tags. -
For the built-in
_tagsfield, use a filter such as:code language-none filter: { _tags: { _expressions: [ { value: "" _operator: CONTAINS } ] } } -
To require all requested tags to be present, use
_logOp: AND. To match any requested tag, use_logOp: OR. -
Verify that the tag data assigned to the Content Fragments is correct and free of errors.
-
After updating the filter, run the query again and verify that the expected Content Fragments are returned.