krisk / Fuse

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

ignoreLocation when useExtendedSearch = true #465

Closed Kjetiljv closed 3 years ago

Kjetiljv commented 4 years ago

Hi!

I had an issue where I did not get the expected search results due to some strings being way longer than others. I updated Fuse to the latest version when the ignoreLocation flag was introduced and this solves the issue if I dont enable useExtendedSearch. However, if I set it to true it looks like ignoreLocation is no longer relevant and I fall back to the default values for location and distance.

Is this expected behavior when using extended search?

krisk commented 4 years ago

Thanks for flagging. Do you have sample data + fuse setup to replicate the issue?

Kjetiljv commented 4 years ago

Tested this on the live demo. It will return the item in list.json As expected since it matches on apple. But if you change useExtendedSearch: true The result array will be empty.

List.json [ { "document": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum apple." }, ]

Main.js

const options = {
  // isCaseSensitive: false,
  // includeScore: false,
  // shouldSort: true,
  // includeMatches: false,
  // findAllMatches: false,
  // minMatchCharLength: 1,
  // location: 0,
  threshold: 0.2,
  // distance: 100,
  useExtendedSearch: false,
  ignoreLocation: true,
  // ignoreFieldNorm: false,
  keys: [
    "document",
  ]
};

const fuse = new Fuse(list, options);

// Change the pattern
const pattern = "Apple"

return fuse.search(pattern)
NevenLiang commented 4 years ago

Same issue here. This is my code sandbox.

When useExtendedSearch is set to true and only using fuzzy search in pattern, the setting ignoreLocation doesn't work. After I set distance to 3000, I can search callback in result.

github-actions[bot] commented 3 years ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

Kjetiljv commented 3 years ago

Just a comment to prevent closing.

vayyala commented 3 years ago

Also running into this issue. We've turned off useExtendedSearch for now because of it, but would love to use it!