krisk / Fuse

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

Won't match entry if query appears after position 70 in the given data set. #455

Closed lucasefe closed 4 years ago

lucasefe commented 4 years ago

Describe the bug

If the string we want to match appears after position 70, in another string which is longer than 70 chars, it won't match it.

Version

Not sure before this, but happens on 6.0.0 up to 6.2.1.

🔬Minimal Reproduction

const assert =  require('assert')
const Fuse = require('fuse.js');

const list = [
  {
    title:  'The Lock Artist',
    author: {
      name: 'Steve Hamilton',
      tags: [
        {
          value: 'The readable English, Many desktop publishing packages and web juliancito'
        }
      ]
    }
  }
];

const options = {
  includeScore: true,
  keys:         [ 'author.tags.value' ]
};

const fuse = new Fuse(list, options);

const result = fuse.search('juliancito');
assert(result.length > 0)
krisk commented 4 years ago

Not a bug 😄

Please check out the scoring theory.

Since you didn't specify the fuzzy-matching options, Fuse.js will use the following values:

With the above options, for something to be considered a match, it would have to be within (threshold) 0.6 x (distance) 100 = 60 characters away from the expected location 0.

Since 70 > 60, it obviously wouldn't match.

Strongly encourage everyone to read the scoring theory for additional insights.

lucasefe commented 4 years ago

Thank you for the insight.

Will read. Much appreciated.