Homepage

Filtering and Sorting

Last edit: Oct 26, 2022

Filtering using Elasticsearch is a slightly different operation from Search, but they are easy to confuse. This topic explains filtering and sorting using GraphQL queries.

Filtering

To filter items by exact value use

  • user: for people
people(user: { first_name: "darek" }) {
  results {
    email
  }
}

Please note, that there is no filter argument in the customizations entry point. You specify filtering operations directly.

{
  customizations(
    page: 1,
    per_page: 210
    properties: [
      { name: "name", value: "alpha|beta" }
    ]
    name: "company"
  ) {
    total_entries
    results {
      id
      name
      properties
    }
  }
}

Sorting

Use sort to change your the ordering of your collection.
When sorting automatically, the raw field is used.

{
  customizations(
    page: 1,
    per_page: 210
    sort: [
      { name: "properties.url", order: "ASC" }
      { name: "properties.name", order: "DESC" }
    ]
    name: "company"
  ) {
    total_entries
    results {
      id
      name
      url: property(name: "url")
      name: property(name: "name")
    }
  }
}

Questions?

We are always happy to help with any questions you may have.

contact us