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:

  1. Confirm that the tags field in the Content Fragment model is a multi-value array rather than a scalar string.

  2. Update the GraphQL filter to use _apply: AT_LEAST_ONCE to match at least one element in the array. For example:

    code language-none
    tags: {
      _expressions: [
        {
          value: ""
          _operator: EQUALS
          _apply: AT_LEAST_ONCE
        }
      ]
    }
    
  3. Use _operator: EQUALS for exact tag ID matches. Use _operator: CONTAINS only for substring or hierarchical matching.

  4. If you’re using a custom tags field, ensure that the filter targets the correct field. The built-in field is _tags.

  5. For the built-in _tags field, use a filter such as:

    code language-none
    filter: {
      _tags: {
        _expressions: [
          {
            value: ""
            _operator: CONTAINS
          }
        ]
      }
    }
    
  6. To require all requested tags to be present, use _logOp: AND. To match any requested tag, use _logOp: OR.

  7. Verify that the tag data assigned to the Content Fragments is correct and free of errors.

  8. After updating the filter, run the query again and verify that the expected Content Fragments are returned.

recommendation-more-help
experience-cloud-kcs-help-kbarticles