Keyword Match Type

Last edit: Jun 10, 2019
  • Contributors:
  • pavelloz

Search by default tries to match the keyword exactly with the words in the field. When you search for alan it will match values alan, but also Mike Alan and Mike Alan and Tommy. You can also define a keyword to match words that start or end with the given phrase.

Match type

For example, you want to search users whose name starts with Al:

query search_people {
  people(query: { keyword: "Al", match_type: ENDS_WITH }) {
    results {
      name
    }
  }
}

Returns users that have name starting with Al*, e.g. Alex, Alan, Alice.

The query argument takes an optional match_type parameter when no specified EXACT is set.

  • EXACT: The keyword "alpha" matches "alpha" OR "alpha gamma" OR any sentence containing exact "alpha" word, This is the default behavior.
  • STARTS_WITH: The keyword "alp" is shortcut for "alp*" and matches "alpha" "alphabet", and any sentence containing any word starting with "alp".
  • CONTAINS: The keyword "alp" is shortcut for "alp" and matches "alpha alphabet somealpha".
  • ENDS_WITH: The keyword "alp" means "*alp" and matches "scalp".

Wildcards

Keyword also accepts the wildcards, ? for a single character, and * for more. For example:

  • al*r* will match alexander, alexandra, but not alex
  • al?n will match alan, alen, but not aleen

Questions?

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