Search...
fuzzy( )
Sets whether to search for exact matches or approximate matches of the search phrase.
Description
If fuzzy
is false
, the search only returns documents containing an exact match of the search phrase.
For example, a search for "applf" or "app" will not return documents containing the phrase "apple".
If fuzzy
is true
, the search returns documents containing exact matches and approximate matches of the search phrase.
For example, a search for "applf" or "app" will return documents containing the phrase "apple".
Note: The default for
fuzzy
istrue
.
Syntax
function fuzzy(fuzzy: boolean): WixSearchBuilder
fuzzy Parameters
NAME
TYPE
DESCRIPTION
fuzzy
boolean
Whether the search is fuzzy or not.
Was this helpful?
Set whether a search is fuzzy
Copy Code
1let newSearch = search.fuzzy(false);
Create a search, set the search to only match the exact search phrase, and run it
Copy Code
1import wixSearch from 'wix-search';23// ...45$w("#searchInput").onKeyPress((keyPress) => {6 if (keyPress.key === "Enter") {7 const phrase = $w("#searchInput").value;8 wixSearch.search(phrase)9 .fuzzy(false)10 .find()11 .then( (results) => {12 if(results.documents.length > 0) {13 let documents = results.documents;14 } else {15 console.log("No matching results");16 }17 })18 .catch( (error) => {19 console.log(error);20 });21 }22});