Ways to execute - Contains some GraphQL Query | Community
Skip to main content
Level 4
November 7, 2022
Solved

Ways to execute - Contains some GraphQL Query

  • November 7, 2022
  • 2 replies
  • 1031 views

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?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SantoshSai

Hi @spidey1405,

Please check this if it helps: https://stackoverflow.com/questions/37981269/how-to-search-string-values-in-graphql

Regards,

Santosh

2 replies

SantoshSai
Community Advisor
SantoshSaiCommunity AdvisorAccepted solution
Community Advisor
November 7, 2022
Santosh Sai
krati_garg
Adobe Employee
Adobe Employee
November 8, 2022

@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