Documentation Center

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.

This first set of samples combines 3 expressions:
  • the binary content type is PDF
  • the publication ID is 7
  • the publication title is "Jap 400 Publication"
In this first sample, an item returned if either the binary content type is PDF, or if it's a publication with both an ID of 7 and a title "Jap 400 Publication", or both.
searchByCriteria(
  criteria:{
    strict:false,
    field:"binaryContentType", 
    value:"application/pdf",
    or:{
      groupBy:{
        field:"publicationId", 
        value:"7", 
        strict:false,
        and:{
          field:"publicationTitle", 
          value:"Jap 400 Publication", 
          strict:false
        }
      }
    }
  }
)
In the second sample, all three conditions must be true.
searchByCriteria(
  criteria:{
    strict:false,
    field:"binaryContentType", 
    value:"application/pdf",
    and:{
      groupBy:{
        field:"publicationId", 
        value:"7", 
        strict:false,
        and:{
          field:"publicationTitle", 
          value:"Jap 400 Publication", 
          strict:false
        }
      }
    }
  }
)
In the third sample, the binary content type must be PDF, and the publication must either have an ID of 7 or a title "Jap 400 Publication".
searchByCriteria(
  criteria:{
    strict:false,
    field:"binaryContentType", 
    value:"application/pdf",
    and:{
      groupBy:{
        field:"publicationId", 
        value:"7", 
        strict:false,
        or:{
          field:"publicationTitle", 
          value:"Jap 400 Publication", 
          strict:false
        }
      }
    }
  }
)
In the fourth sample, again, all three conditions must hold, but in addition, strict is enabled for the first operand, forcing an exact string match.
searchByCriteria(
  criteria:{
    strict:true,
    field:"binaryContentType", 
    value:"application/pdf",
    and:{
      groupBy:{
        field:"publicationId", 
        value:"7", 
        strict:false,
        and:{
          field:"publicationTitle", 
          value:"Jap 400 Publication", 
          strict:false
        }
      }
    }
  }
)
Here is another set of samples. The first sample returns the smallest amount of items, as it requires all three operands to be true:
{
  searchByCriteria(
    criteria: {
      strict: false, 
      field: "publicationId", 
      value: "5", 
      and: {
        groupBy: {
          field: "itemType", 
          value: "component", 
          and: {
            field: "content+english", 
            value: "From", 
            strict: true
          }
        }
      }
    }
  ) 
  {
    edges {
      cursor
      node {
        searchResult {
          id
          rawLanguageTitle
        }
      }
    }
  }
}
The second sample doesn't require the content to contain the word "From" and be a Component; either one is already sufficient. Accordingly, this query returns more results than the previous one:
{
  searchByCriteria(
    criteria: {
      strict: false, 
      field: "publicationId", 
      value: "5", 
      and: {
        groupBy: {
          field: "itemType", 
          value: "component", 
          or: {
            field: "content+english", 
            value: "From", 
            strict: true
          }
        }
      }
    }
  ) 
  {
    edges {
      cursor
      node {
        searchResult {
          id
          rawLanguageTitle
        }
      }
    }
  }
}
Our third sample returns the largest number of results, since both operators are OR. Accordingly, matching results from any Publication are returned:
{
  searchByCriteria(
    criteria: {
      strict: false, 
      field: "publicationId", 
      value: "5", 
      or: {
        groupBy: {
          field: "itemType", 
          value: "component", 
          or: {
            field: "content+english", 
            value: "From", strict: true
          }
        }
      }
    }
  ) 
  {
    edges {
      cursor
      node {
        searchResult {
          id
          rawLanguageTitle
        }
      }
    }
  }
}