AEM GraphQL nested AND and OR expression | Community
Skip to main content
iamnjain
Community Advisor
Community Advisor
May 8, 2023

AEM GraphQL nested AND and OR expression

  • May 8, 2023
  • 2 replies
  • 1827 views

Hello People,

 

Is there a way to apply two _logOp in single GraphQL query?

we have a query, where we want to filter result in a folder AND it should match the variable value between two CF model fields, so It should be OR operation.

Is there a way, we can do it in AEM GraphQL syntax?

 

Thanks.

 

@arunpatidar 

 

2 replies

krati_garg
Adobe Employee
Adobe Employee
May 8, 2023

@iamnjain I believe CF Model fields and Folder structure would really help in constructing the query. Also, please share any sample query that you must have tried

iamnjain
Community Advisor
iamnjainCommunity AdvisorAuthor
Community Advisor
May 8, 2023

Sure @krati_garg 

Here is sample query


query SearchInFolder ($searchString:String!) {
questionandanswerList(filter:{
_path:{
_expressions: [
{
value:"/content/dam/testproject/contentfragments/qanda"
_operator:STARTS_WITH
}
]
}
_logOp: AND
question:{
_expressions: [
{
value: $search
_operator: CONTAINS
_ignoreCase: true
}
]
}
answer:{
_expressions: [
{
value: $search
_operator: CONTAINS
_ignoreCase: true
}
]
}
}
)
{
items {
question
answer
}
}
}

 

Here, the requirement is, It should search inside that folder AND should match the keyword either with question OR answer field. So It's an OR operation.

 

How to nest AND and OR operator in one single query?

May 17, 2024

Hello, did you find a solution for your problem? 

Same probelm here.

I need to search a word in two different fields in OR condition.

 

Ty

iamnjain
Community Advisor
iamnjainCommunity AdvisorAuthor
Community Advisor
May 18, 2024

Nope.