Own search function as an alternative to fuse.js
Closed this issue · 1 comments
Es wäre cool, eigene Suchfunktion zu verwenden anstatt fuse.js zu nutzen. Ein großes Problem ist z.B. folgendes
const list = [{ product: "Nike Trail Running Shoes" }]
const options = {
includeScore: true,
ignoreLocation: true,
keys: ["product"],
};
const fuse = new Fuse(list, options);
return fuse.search(pattern);
If pattern = "Nike" score will be 0.03
But if pattern = "Nike shoes" score will be 0.655
I want "Nike shoes" to get a better score than "Nike", since it contains both Nike and shoes
https://stackoverflow.com/questions/74776336/how-to-split-the-pattern-with-fuse-js
Tuning Fuse (ie fuse options) is outside the scope of this project, more something to take up with Fuse.js directly.
The search backend can be completely replaced by setting instance._searcher
in the callbackOnInit
method. You probably can just monkey patch the instance._searcher.search()
method if you are just enhancing how fuse is used.
The fuse search implementation is found in this file:
https://github.com/Choices-js/Choices/blob/5fa376b2f902594bc75de268d545c70d11ce8d51/src/scripts/search/fuse.ts