This guide uses the
mock_items
table.Fuzzy Term
Suppose we want to find all documents containingshoes
, but the user typed in shoez
. The fuzzy_term
query can find search results that approximately match the query term while allowing for minor typos in the input.
Expected Response
Expected Response
Fuzzy Matching
Suppose the user provides a misspelled phrase likeruining shoez
when searching for running shoes
. Because fuzzy_term
treats value
as a single token,
passing the entire phrase to fuzzy_term
will not yield any matches. Instead, match
should be used. match
finds documents where
any of the query’s tokens are a fuzzy match.
Expected Response
Expected Response
match
can be configured to match documents if all query tokens match.
Expected Response
Expected Response
Multiple Fuzzy Fields
Suppose we want to compare a query against bothdescription
and category
. The boolean
query can be used to query across multiple fields.
Expected Response
Expected Response
Ngram Term
Suppose we want to suggest results when the user has only typed part of a word, likesho
. In this scenario,
the ngrams tokenizer can be used to convert documents into ngram tokens.
For the purpose of this example, let’s assume that we have an index called ngrams_idx
:
description
tokenized into n-grams, we can search for partial words.
Expected Response
Expected Response
Ngram Term Set
When querying against an ngrams field, all ngrams of the query must match in order for the document to be considered a match. This means that a query likehsoes
does not match shoes
, because the hso
token does not match any of the tokens of shoes
.
To match documents where any ngram token of the query matches, the match
query can again be used. Since we are looking for
exact ngram matches, the distance
parameter can be lowered to 0
.
Expected Response
Expected Response
Further Customization
This guide has demonstrated how the query builder functions likeparadedb.boolean
can be used to compose new, powerful queries.
We encourage you to use these functions to experiment with queries that satisfy your use case.