Created
October 29, 2024 16:13
-
-
Save c7x43t/077bfc74393b8502d2171711eb1bdd58 to your computer and use it in GitHub Desktop.
Flexsearch fuzzy search
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Initialize a FlexSearch Document index with typo-tolerance and partial matching for products | |
const flexIndex = new FlexSearch.Document({ | |
preset: 'match', | |
charset: "latin:advanced", | |
tokenize: "full", | |
resolution: 20, | |
document: { | |
id: "id", | |
index: [ | |
{ | |
field: "text", | |
tokenize: "full", | |
threshold: 5, | |
resolution: 9, | |
depth: 5 | |
} | |
] | |
}, | |
context: { | |
resolution: 7, | |
depth: 5, | |
bidirectional: true | |
} | |
}); | |
// Don't know why but this yields fuzzy search. charset and context contribute the most i think. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment