Keyword Match Type
Last edit: Oct 26, 2022
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 matchalexander
,alexandra
, but notalex
al?n
will matchalan
,alen
, but notaleen