krisk / Fuse

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

This doesn't seem to work at all. Am I missing something obvious? #550

Closed old-zoomer closed 3 years ago

old-zoomer commented 3 years ago

Describe the bug

I am trying to search for a string that is present in search array, and get no results.

Version

6.4.6

🔬Minimal Reproduction

const list = [{
  "speaker": {
    "name": "Speaker name"
  },
  "text": "Oh yeah, sure. So my name is Michaela. I'm here at the mountain. I've been doing all stuck development software, engineering Cloud development. In software companies. and now, Naughty became my passion. So I'm really excited to speak with you to know how maybe you can help us to reach the next level, you know. and yeah, that pretty much it maybe"
}]

const options = {
  // isCaseSensitive: false,
  // includeScore: false,
  // shouldSort: true,
  // includeMatches: false,
  // findAllMatches: false,
  // minMatchCharLength: 1,
  // location: 0,
  // threshold: 0.6,
  // distance: 100,
  // useExtendedSearch: false,
  // ignoreLocation: false,
  // ignoreFieldNorm: false,
  keys: ['text', 'speaker.name']
};

const fuse = new Fuse(list, options);

// Change the pattern
const pattern = "engineering Cloud development"

return fuse.search(pattern) // returns [];
lukasd2 commented 3 years ago

Hey, I don't think this is a bug. The issue here is the distance option that defaults to 100. Your variable "list" contains your desired string "engineering Cloud development" that comes definitely after the first 100 characters. You could try to increase the distance or location as specified in the docs. Should not be connected to the version 6.4.6. You can check your example and verify that it is working in the live playground (https://fusejs.io/demo.html). Hope that helps.

puttehi commented 2 years ago

Definitely doesn't work on Node 12 at least.