Expand my Community achievements bar.

SOLVED

Ways to execute - Contains some GraphQL Query

Avatar

Level 5

Is it possible to query contains some using GQL in AEM?

 

Example: 

title contains: ["Health","doctor","medicine"]

 

If it contains anyone of them then return true.

 

One way would be to individually add these elements:

{
      _expressions: [
        {
          _operator:CONTAINS
          value:"health"
        }
        {
          _operator:CONTAINS
          value:"Health"
        }
        {
          _operator:CONTAINS
          value:"healthy"
        }

      ]

 

However I was interested in knowing a better solution like:

{
      _expressions: [
        {
          _operator:CONTAINS
          values: [
            "Health",
            "health"
          ]
        }

      ]
    }

 

I get : Cannot compare single value to an array. when I implement the above. I wanted to know the only way possible to query contains_some is by first method?

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

@spidey1405 
Ideally the example quoted above would not require 3 values to be compared

{
_expressions: [
{
_operator:CONTAINS
_ignoreCase: true
value:"health"
}

]
}

However, if its just a sample content. the method quoted by @SantoshSai could be explored

View solution in original post

2 Replies

Avatar

Correct answer by
Employee Advisor

@spidey1405 
Ideally the example quoted above would not require 3 values to be compared

{
_expressions: [
{
_operator:CONTAINS
_ignoreCase: true
value:"health"
}

]
}

However, if its just a sample content. the method quoted by @SantoshSai could be explored