Fuzzy Search
-
A fuzzy search retrieves documents containing terms that closely match a given term rather than exact matches, assisting in finding relevant results when the search term is misspelled or has minor variations.
-
In this page:
Fuzzy search example
/** @var array<Company> $companies */
$companies = $session->advanced()
->documentQuery(Company::class)
// Query with a term that is misspelled
->whereEquals("Name", "Ernts Hnadel")
// Call 'Fuzzy'
// Pass the required similarity, a decimal param between 0.0 and 1.0
->fuzzy(0.5)
->toList();
// 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
public function fuzzy(float $fuzzy): DocumentQueryInterface;
Parameter | Type | Description |
---|---|---|
$fuzzy | float |
A value between 0.0 and 1.0 .With a value closer to 1.0 , terms with a higher similarity are matched. |
Return Type | Description |
---|---|
DocumentQueryInterface |
Query results |