Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All indices return with threshold = 0 aren't a perfect match #762

Open
1 task done
dbismut opened this issue Mar 4, 2024 · 0 comments · May be fixed by #766
Open
1 task done

All indices return with threshold = 0 aren't a perfect match #762

dbismut opened this issue Mar 4, 2024 · 0 comments · May be fixed by #766
Labels

Comments

@dbismut
Copy link

dbismut commented Mar 4, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Description of the bug

Version 7.0 (but reproductible in 6.6.2)

It seems like when using a threshold of 0 combined with ignoreLocation to return a perfect match, as long as there is one perfect match in the searched text, all other groups of matches are returned no matter how fuzzy they are.

JSFiddle: https://jsfiddle.net/dp4efm2s/12/

The Fuse.js version where this bug is happening.

7.0.0

Which version did this behavior use to work in?

Not sure

Steps To Reproduce

const list = [
{ title: 'rouge desert groue'},
]

const fuseOptions = {
  //isCaseSensitive: false,
  includeScore: true,
  shouldSort: false,
  includeMatches: true,
  findAllMatches: false,
  minMatchCharLength: 2,
  threshold: 0,
  ignoreLocation: true,
  keys: ["title"]
};

const fuse = new Fuse(list, fuseOptions);

// Change the pattern
const searchPattern = "rouge"

console.log(fuse.search(searchPattern))

Here is the returned object:

[{
  item: {
    title: "rouge desert groue"
  },
  matches: [{
  indices: [[0, 4], [9, 10], [13, 17]],
  key: "title",
  value: "rouge desert groue"
}],
  refIndex: 0,
  score: 0.01857804455091699
}]

Expected behavior

There is only one perfect matching indice — which is the first one — so only one indice should be returned:

[{
  item: {
    title: "rouge desert groue"
  },
  matches: [{
  indices: [[0, 4]], // only ONE indice should be returned
  key: "title",
  value: "rouge desert groue"
}],
  refIndex: 0,
  score: 0.01857804455091699
}]

Screenshots

No response

Additional context

No response

@dbismut dbismut added the bug label Mar 4, 2024
@RomanHotsiy RomanHotsiy linked a pull request May 4, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant