Dev guideRecipesAPI ReferenceChangelog
Dev guideRecipesUser GuidesNuGetDev CommunityOptimizely AcademySubmit a ticketLog In
Dev guide

Filter

Introduces filtering in Optimizely Graph.

Filtering in Optimizely Graph lets you refine query results by specifying the conditions a content item must meet, so the API returns only the records the application needs. Use filters to reduce payload size, speed up queries, and keep the UI free of irrelevant data, whether you are working against a large content tree or a deeply nested schema.

Key features of filters in Optimizely Graph

Two feature areas extend the base filter operators to cover combined logic and geographic data. Start here when you need to compose multiple conditions or rank results by location.

  1. Logical connectors – Combine multiple filtering conditions. Logical connectors such as _and, _or, and _not let you build complex query logic by applying multiple criteria simultaneously to refine your data further.
  2. Geo search – Filter based on geographical data. Geo search is useful for applications that provide location-based results, such as finding nearby stores or events.

Exact filtering

Exact filtering selects records by matching a single value or one of a set of values, which is the right choice when the query knows the precise input ahead of time.

  • eq (equals) – Filters data based on a single exact value. It is useful for querying fields to find entries that match a specific criterion, for example, filtering user records by a specific email address.
  • in – Lets you filter based on multiple exact values, effectively handling lists. It is ideal when you must find entries that match any value within a specified set, such as retrieving products that belong to multiple specified categories.

Example

The following GraphQL query returns content items whose Email field exactly matches the supplied address:

{
  Content(where: { Email: { eq: "[email protected]" } }) {
    items {
      Name
    }
  }
}

Partial string filtering

Partial string filtering selects records by matching a prefix or suffix, which is the right choice when the calling layer knows part of the value but not the full string.

  • startsWith – Lets you filter data by checking whether a field starts with a particular string pattern. It is useful for searches that require prefix matching, such as finding user names that start with John.
  • endsWith – Lets you filter data by matching the suffix of a string. It is effective for searches that find entries ending with specific characters, such as file extensions or last names.