krisk / Fuse

Lightweight fuzzy-search, in JavaScript
https://fusejs.io/
Apache License 2.0
17.79k stars 756 forks source link

findAllMatches broken #547

Closed dodlhuat closed 3 years ago

dodlhuat commented 3 years ago

Describe the bug

there seems to be an issue with scores already mentioned here https://github.com/krisk/Fuse/issues/545 which may lead to the problem that findAllMachtes never finds a perfect match and therefore always shows partial matches

Version

6.4.6.

Is this a regression?

already happened in 6.4.1

🔬Minimal Reproduction

    const options = {
        findAllMatches: false,
        threshold: 0.3,
        keys: ["name"],
      };

   const results = (new Fuse([{name: 'Auditor'}, {name: 'Auditee'}], options)).search('Auditor');
dodlhuat commented 3 years ago

Unfortnuately it seems like fuse is dead and I have to switch to another option for fuzzy search.

krisk commented 3 years ago

As I mentioned in the #545, this is by design. See scoring theory for more info.

dodlhuat commented 3 years ago

In this case findAllMatches can be removed as it never will work, or needs to be tweaked to already work with very low comparison differences

dodlhuat commented 3 years ago

For anyone also running into this problem, as score never returns 0 and findAllMatches is looking for a zero which will never appear, I simply added a check on my own that looks for a score near 0 which counts as an exact match. This might not be the best solution as it can return false positives, but was the only way I could think of.