Skip to content

Instantly share code, notes, and snippets.

@c7x43t
Created October 29, 2024 16:13
Show Gist options
  • Save c7x43t/077bfc74393b8502d2171711eb1bdd58 to your computer and use it in GitHub Desktop.
Save c7x43t/077bfc74393b8502d2171711eb1bdd58 to your computer and use it in GitHub Desktop.
Flexsearch fuzzy search
// 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