fuzzy matching for search results via fuse.js #482
karaliunas
started this conversation in
Ideas
Replies: 2 comments 1 reply
-
Maybe something like this: class FuzzyTom extends TomSelect{
// override search method
search(query){
let results = fuse.search(querystring);
//...
return results;
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
-
or not Fuse |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to implement a custom plugin to integrate fuse.js lib to enable approximate string matching. It would be a useful plugin for some e-commerce cases when setting up a dedicated backend (ElasticSearch or Algolia) would simply be too much just to handle search.
I can get a query string and bind to load hook to get fuzzy matching results data from fuse.js in the console. It has a score property for each match so I think it would be possible to use it for sorting.
self.on('type', (str: string) => { querystring = str; }),
self.on('load', (items: []) => { if (querystring.length === 0) { return; } const fuse = new Fuse(items, options); const result = fuse.search(querystring); console.log(result); });
Now I am stuck because I don't know how to pass those results to
refreshOptions
method (it is there where the logic of finding results is implemented). What I think we need is an additional hook to augment currently internalsearch(query:string)
method. Maybe creating a hook in search method something like this:if (trigger) self.trigger('search', queryString);
would be enough? I would be willing to create a PR for that. Thanks!Beta Was this translation helpful? Give feedback.
All reactions