krisk / Fuse

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

substrings only match if occur in first 41 characters #49

Closed robert-king closed 8 years ago

robert-king commented 9 years ago

"zyxwvutsrqpomnlkjihgfedcbaabcdefghijklmnopqrstuvwxyz".length == 52

searching for "pqrstuv" finds nothing.. searching for "opqrstu" gets a match.

"zyxwvutsrqpomnlkjihgfedcbaabcdefghijklmno".length == 41

95% of my strings are less than length 41 anyway & 99.9% of searches are substrings that occur in the first 41 characters anyway. Another fix is to split the string in half across two keys.

Anyway - thought it was worth posting this issue just FYI since lots of people will use fuse.js

mrienstra commented 9 years ago

Probably related to #38

jeancroy commented 9 years ago

Have you tried playing with the distance or threshold options? They'll affect how far away from start bitap will loop for a match before bail out.

    // Determines how close the match must be to the fuzzy location (specified above).
    // An exact letter match which is 'distance' characters away from the fuzzy location
    // would score as a complete mismatch. A distance of '0' requires the match be at
    // the exact location specified, a threshold of '1000' would require a perfect match
    // to be within 800 characters of the fuzzy location to be found using a 0.8 threshold.
    distance: 100,

    // At what point does the match algorithm give up. A threshold of '0.0' requires a perfect match
    // (of both letters and location), a threshold of '1.0' would match anything.
    threshold: 0.6,