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

Closed
1 task done
dbismut opened this issue Mar 4, 2024 · 1 comment · May be fixed by #766
Closed
1 task done

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

dbismut opened this issue Mar 4, 2024 · 1 comment · May be fixed by #766

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

Copy link

github-actions bot commented Jul 3, 2024

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

@github-actions github-actions bot added the Stale label Jul 3, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant