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

Operators

Describes operators for fields used with the GraphQL API, for the Optimizely querying service, when retrieving content in Optimizely solutions.

Operators in Optimizely Graph let you control exactly how a query matches each field, so you can pick the best match strategy for site search, exact lookups, ranges, and wildcards. Choose the operator that fits the field type and the user experience you want to deliver.

For every field, add an operator to match the content of that field in a particular way.

📘

Note

When null is used as a value with an operator, the query ignores the matching. For example, exist:null is ignored.

Optimizely Graph supports the following operators:

  • match – Optimized for returning the most relevant results and applying common text-matching techniques. It works on searchable string fields, which contain large chunks of text. It returns more relevant results than contains and returns more results in general, offering a better user experience for site visitors. Use the match operator as a default operator for site search.
  • contains – Performs a full-text search on a word or phrase, with support for language stemming when you add the locale parameter. It matches on terms tokenized by word boundaries according to UAX #29: Unicode Text Segmentation. When matching on a term with a leading or trailing punctuation character, Optimizely Graph ignores these characters. It is the recommended operator for full-text search.
  • eq – Matches an exact literal value. The value is case-insensitive, but results matching cases are ranked higher.
  • notEq – Retrieves results not matching with an exact literal (but case-insensitive) value.
  • gt – Retrieves results with matches that have a value that is greater than the value.
  • gte – Retrieves results with matches that have a value that is greater than or equal to the value.
  • lt – Retrieves results with matches with a value of less than the value.
  • lte – Retrieves results with matches with a value of less than or equal to the value.
  • exist – Matches results that have this field with a value.
  • startsWith – Retrieves matches that start with a certain value (prefix). It is case-insensitive.
    Example: startsWith: "eng" matches "English" or "english", and also "engineering".
  • endsWith – Retrieves matches that end with a certain value (suffix). It is case-insensitive.
    Example: endsWith: "lish" matches "English" or "bullish".
  • in – Matches with one or more exact literal (case-sensitive) values in a list.
    Example: in: ["word1", "word2", "this is a phrase"]
  • notIn – Returns results that do not match with one or more exact literal (case-sensitive) values in a list.
    Example: notIn: ["word1", "word2", "this is a phrase"]
  • like – Matches substrings with wildcard support. Example: % to match on zero or more characters, _ to match on any character.
🚧

Important

For fields with the type SearchableStringFilterInput, leading wildcards only match on the whole value (alphanumeric string or single token) when wrapped with both a leading and trailing % character. So, it does not match on a prefix within a word.

Leading with only wildcards is not supported at the beginning of a whole value (such as a single word and sentence) and results in an error. However, leading wildcards are supported for words within a sentence, not phrases.

Examples:

  • like: "%app%" – Only matches whole words such as "app", "applications", "apple", "apples", and so on. It also matches phrases such as "Optimizely apps are the most awesome!".
  • like: "Course %ollaboration Mad% Simple" – A sentence with a leading wildcard for a word within it, and matches "Course Collaboration Made Simple".
  • like: "%ears" – A leading wildcard with a single word and results in an error.
  • like: "%Course Collaboration Mad% Simple" – A sentence starting with a leading wildcard and results in an error.
  • like: "%_ourse %ollaboration Mad% Simple%"– A phrase containing a leading wildcard in a word and results in an error.

For fields with the type StringFilterInput, matching (on a substring) with a leading wildcard is supported.

Examples:

  • like: "%pp%" – Matches on "app", "applications", "whopper", and so on.
  • like: "%ears" – Matches on "ears", "bears", "years", and so on.