Can we pass multiple string values for a single filter to fetch the CF response | Community
Skip to main content
Level 2
March 12, 2026
Question

Can we pass multiple string values for a single filter to fetch the CF response

  • March 12, 2026
  • 4 replies
  • 52 views

I have a requirment where we have a listing page with restaurants (cards). There is a filter and when end user select single filter example cuisine=french. im able to fetch the data from graphql query and return the CFs which has a tag called french. Now if end user selects multiple filters like french and italian then i need to show all the CFs which has tags french and italian through graphql.

 

I have tried multiple ways but im getting null values
sample query:
query getDiningList( $langcode: String,$tag1: [String], $tag2:String,$offset: Int,$limit: Int) {
  diningList(
    includeVariations: true
    _locale:$langcode
    offset: $offset
    limit: $limit
       filter:{
        _path:{
        _expressions:[
          {_operator: STARTS_WITH,value:"/content/dam/test/cfm"}
        ]
        },
      cuisineTag:{
         _logOp:OR
        _expressions:[{_operator:CONTAINS , values:$tag1}],
      }
        locationTag:{
           _expressions:[{_operator: CONTAINS, value:$tag2}]
        }
    }
  ){
      items{
                        _path
               __typename
                title
                categoryTag
                cuisineTag
                locationTag
                teaserTitle
                teaserDescription

  }
  }
}
 

Sample endpoint URL: /graphql/execute.json/test/getDiningListing;langcode=en;tag1=french,italian;offset=0;limit=6;

Is this endpoint url correct for sending multiple string values for tag1? 

Provide an approach whether we can fetch the data with a filter having multiple string values or should we try with any alternative approach?

    4 replies

    rk_pandian
    Level 4
    March 12, 2026

    Hello ​@Saiteja-09 , I see that the difference here is the value and values keyword.

    • value - can accept one String
    • values - can accept multiple Strings

    In the above code inside cuisineTag block, the first expression has values, but I dont think an array is being sent there.

    If you want to check against multiple Strings, use values followed by [String1,String2] etc. Below is my example to check multiple arguments against one field. I went with tagfield here to stick with your scenario.

    Please note that CONTAINS operator didn’t work with String array. I tried with IN but it seems that we need a service pack (depending on the current AEM version) and another graphql package to make it work. Unfortunately I was not able to test it out today.

    In your case, if you have less filters, then pass them as separate variables and use them for each value.

    For multiple values, pass as an Array from the client side.

    Hope this helps.

    {
    viewModeModelList(filter:
    {
    viewMode: {
    _logOp: OR
    _expressions: [
    {
    value: "properties:orientation/portrait",
    _operator: EQUALS
    }
    {
    value: "properties:orientation/landscape",
    _operator: EQUALS
    }
    # {
    # values: ["properties:orientation/landscape","properties:orientation/portrait"],
    # _operator: IN
    # }
    ]
    }
    }) {
    items {
    viewMode
    }
    }
    }

     

    Regards,

    Ramkumar

    AmitVishwakarma
    Community Advisor
    Community Advisor
    March 13, 2026

    Hi ​@Saiteja-09 

    Yes, you can filter by multiple tag values – your GraphQL is close, the URL variables are wrong.

    1. GraphQL (recommended pattern)

    query getDiningList(
    $langcode: String
    $cuisines: [String] # multi-value variable
    $location: String
    $offset: Int
    $limit: Int
    ) {
    diningList(
    includeVariations: true
    _locale: $langcode
    offset: $offset
    limit: $limit
    filter: {
    _path: {
    _expressions: [{ _operator: STARTS_WITH, value: "/content/dam/test/cfm" }]
    }
    cuisineTag: {
    _logOp: OR
    _expressions: [{ _operator: EQUALS, values: $cuisines }]
    }
    locationTag: {
    _expressions: [{ _operator: CONTAINS, value: $location }]
    }
    }
    ) {
    items { _path title cuisineTag locationTag }
    }
    }

    2. How to pass multiple values

    Your URL:

    ...;tag1=french,italian;...

    is treated as one string, not a list.

    Use either:

    Headless SDK (best):

    runPersistedQuery("test/getDiningListing", {
    langcode: "en",
    cuisines: ["french", "italian"],
    location: "paris",
    offset: 0,
    limit: 6
    });

    Or raw URL with a list literal (then URL‑encode it):

    /graphql/execute.json/test/getDiningListing;cuisines=["french","italian"];langcode=en;offset=0;limit=6

    That will correctly return CFs tagged with french OR italian.

    Amit Vishwakarma - Adobe Commerce Champion 2025 | 16x Adobe certified | 4x Adobe SME
    kautuk_sahni
    Community Manager
    Community Manager
    March 16, 2026

    @Saiteja-09 Quick follow-up! Were you able to resolve this issue? If so, it would be great if you could share what worked for you so others can benefit. Also, if any of the replies helped, whether they fully solved it or just guided you in the right direction, please consider marking one as accepted. It really helps future community members find solutions faster. Closing the loop makes a big difference!

    Kautuk Sahni
    PGURUKRISHNA
    Level 4
    March 16, 2026

    Hey ​@Saiteja-09 

    Your endpoint URL format is incorrect. Semicolon-separated parameters in AEM persisted query URLs don't automatically parse comma-separated values into arrays. So 

    tag1=french,italian

     is being passed as the literal string 

    "french,italian"

    , not as an array 

    ["french", "italian"]

    .

    Solution There are two parts to fix:

    1. Query Definition

    Your query variable type 

    $tag1: [String]

     (array) is correct. But the filter expression should use 

    values

     (plural) with the 

    CONTAINS

     operator properly. Here's the corrected query:

    query getDiningList(
    $langcode: String
    $tag1: [String]
    $tag2: String
    $offset: Int
    $limit: Int
    ) {
    diningList(
    includeVariations: true
    _locale: $langcode
    offset: $offset
    limit: $limit
    filter: {
    _path: {
    _expressions: [
    { _operator: STARTS_WITH, value: "/content/dam/test/cfm" }
    ]
    }
    cuisineTag: {
    _expressions: [
    { _operator: CONTAINS, values: $tag1 }
    ]
    }
    locationTag: {
    _expressions: [
    { _operator: CONTAINS, value: $tag2 }
    ]
    }
    }
    ) {
    items {
    _path
    __typename
    title
    categoryTag
    cuisineTag
    locationTag
    teaserTitle
    teaserDescription
    }
    }
    }

     

     

    Key points:

    • Use 

      values
       (plural) with 
      $tag1
       since it's an array type
    • Remove the 

      _logOp: OR
       at the field level — the 
      CONTAINS
       operator with 
      values
       already checks if the field contains any of the provided values (OR logic by default)

    2. Endpoint URL Format

    For array parameters in AEM persisted query URLs, you need to pass each value separately using repeated semicolons:

    /graphql/execute.json/test/getDiningListing;langcode=en;tag1=french;tag1=italian;offset=0;limit=6

     

    Not 

    tag1=french,italian

     — that sends a single string.

    Alternative: POST Request Approach

    If the persisted query URL encoding becomes problematic, you can call the persisted query via POST with a JSON body, which handles arrays cleanly:

    {
    "query": "",
    "operationName": "getDiningList",
    "variables": {
    "langcode": "en",
    "tag1": ["french", "italian"],
    "tag2": "downtown",
    "offset": 0,
    "limit": 6
    }
    }

     

    POST to: 

    /graphql/execute.json/test/getDiningListing

    This is generally more reliable for complex filter scenarios with array values.

    If Tags Are Stored as Full Paths

    If your Content Fragment stores tags as full tag paths (e.g., 

    cuisine:french

    ), make sure you pass the full tag ID in the filter values:

    ;tag1=cuisine:french;tag1=cuisine:italian

     

    • Use 

      values
       (plural) in the filter expression for array variables
    • Pass array params by repeating the parameter name in the URL: 

      tag1=french;tag1=italian
    • Consider using POST with JSON variables for cleaner array handling

    • Ensure tag values match the exact format stored in the Content Fragments

    Pagidala GuruKrishna
    Level 2
    March 24, 2026

    hi ​@PGURUKRISHNA I have tried with adding tag1 multiple times as mentioned like ;tag1=cuisine:french;tag1=cuisine:italian and used the values in the graphql.

    Points Noticed:

    If I give same tag multiple times it is taking the last given variable like tag1=french;tag1=italian. It is taking italian and ignoring french.

    tried to make a POST call and provide it in array from body with JSON structure, this time im able to get all the data instead filtered data.