GraphQL requests using Boolean expressions with more than two operands
Use groupBy to combine a two-operand Boolean expression with a third operand, to form a three-operand Boolean expression.
The following is a basic example that demonstrates the use of
groupBy to combine one two-operand AND expression with a third operand to form another AND expression:
search (
criteria: {
groupBy: {
field: {
key: "publicationTitle",
value: "Example Site"
},
and: {
languageField: {
language: "english",
key: "content",
value: "ooo"
}
}
},
and: {
field: {
key: "publicationId",
value: "5"
}
}
}
)
The above query retrieves all items for which all three filter expression apply:
- the
publicationTitlefield has the valueExample, and - the English
contentfield has the valueooo, and - the
publicationIdfield has the value 5
An example using concepts and specifying facets and results is the following, which requires all three specified concepts to be present in the queried item:
{
search(
criteria: {
groupBy: {
concept: {
connectorId: "politics",
conceptIds: ["eurovoc-europa-eu_2262"]
},
and: {
concept: {
connectorId: "FPPCONCEPTS66ENERGY",
conceptIds: ["eurovoc-europa-eu_1414"]
}
}
},
and: {
concept: {
connectorId: "FPPCONCEPTS24FINANCE",
conceptIds: ["eurovoc-europa-eu_2632"]
}
}
},
facets: {
concepts: [
{
connectorId: "politics",
first: 5,
language: "english"
}
]
}
)
{
facets(language: "english") {
__typename
... on ConceptFacet {
concepts {
id
count
label
uri
}
connectorId
title
uri
concepts {
label
id
}
}
}
results {
edges {
node {
search {
id
rawLanguageTitle
locale
}
broker {
itemId
title
}
}
}
}
}
}
This next example combines a two-operand AND expression with a third operand using the OR operator:
{
my68: search (
criteria: {
groupBy: {
languageField: {
key: "content",
language: "english",
value: "Digital Experience"
},
and: {
concept: {
conceptLabels: ["Docs Content Editor"],
connectorId: "productbreakdown"
}
}
},
or: {
concept: {
conceptLabels: ["Authoring"],
connectorId: "usergoals"
}
}
}
)
{
results {
hits
edges {
node {
search {
id
score
conceptSchemes {
concepts {
label
}
}
mainContentField
}
}
}
}
}
}
The following query is very similar to the previous one, but it combines all three operands using AND operators:
{
my1: search (
criteria: {
groupBy: {
concept: {
conceptLabels: ["Authoring"],
connectorId: "usergoals"
},
and: {
concept: {
conceptLabels: ["Docs Content Editor"],
connectorId: "productbreakdown"
}
}
},
and: {
languageField: {
key: "content",
language: "english",
value: "Digital Experience"
}
}
}
)
{
results {
hits
edges {
node {
search {
id
score
conceptSchemes {
concepts {
label
}
}
mainContentField
}
}
}
}
}
}
And this query combines all operands using OR operators:
{
my208: search (
criteria: {
groupBy: {
concept: {
conceptLabels: ["Authoring"],
connectorId: "usergoals"
},
or: {
concept: {
conceptLabels: ["Docs Content Editor"],
connectorId: "productbreakdown"
}
}
},
or: {
languageField: {
key: "content",
language: "english",
value: "Digital Experience"
}
}
}
)
{
results {
hits
edges {
node {
search {
id
score
conceptSchemes {
concepts {
label
}
}
mainContentField
}
}
}
}
}
}