Fuzzy Search
-
A fuzzy search retrieves documents containing terms that closely match a given term instead of exact matches, assisting in finding relevant results when the search term is misspelled or has minor variations.
-
Use the
fuzzy
method when querying withwhereEquals
. -
In this page:
Fuzzy search example
const employees = await session
.query({ collection: "Companies" })
// Query with a term that is misspelled
.whereEquals("Name", "Ernts Hnadel")
// Call 'fuzzy'
// Pass the required similarity, a number between 0.0 and 1.0
.fuzzy(0.5)
.all();
// Running the above query on the Northwind sample data returns document: companies/20-A
// which contains "Ernst Handel" in its Name field.
from "Companies"
where fuzzy(Name = "Ernts Hnadel", 0.5)
Syntax
fuzzy(fuzzy);
Parameter | Type | Description |
---|---|---|
fuzzy | number |
A value between 0.0 and 1.0 .With a value closer to 1.0 , terms with a higher similarity will be matched. |