Should-be perfect match has non-zero score
See original GitHub issueDescribe the bug
When searching for a keyword in a list of objects, the search works and finds matches. However, the should-be perfect matches return a non-zero score like 2.220446049250313e-16
. This should be 0 as it is a perfect match, but due to not being exactly 0, it continues the search.
The Minimal Production below gives this as its result:
0: {item: {…}, refIndex: 0, matches: Array(1), score: 2.220446049250313e-16}
1: {item: {…}, refIndex: 1, matches: Array(1), score: 0.2}
2: {item: {…}, refIndex: 2, matches: Array(1), score: 0.2}
3: {item: {…}, refIndex: 3, matches: Array(1), score: 0.2}
4: {item: {…}, refIndex: 4, matches: Array(1), score: 0.2}
Version
6.4.1
Is this a regression?
Yes, the previous version in which this bug was not present was: 3.6.1 (Im using it in another project, there it works fine)
🔬Minimal Reproduction
const items = [
{
value : 'test1',
},
{
value : 'test2',
},
{
value : 'test3',
},
{
value : 'test4',
},
{
value : 'test5',
},
];
const fuse = new Fuse(items, {
ignoreLocation : true,
includeMatches : true,
includeScore : true,
keys : ['value'],
});
console.log(fuse.search('test1'));
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:5
Top Results From Across the Web
Lecture 12 1 Review 2 Perfect Matching
such a matching is perfect if every vertex has exactly one edge incident on it. ... permutations will also yield a non-zero result....
Read more >When to stop dating and settle down, according to math
The magic figure turns out to be 37 percent. To have the highest chance of picking the very best suitor, you should date...
Read more >Lecture 1: Perfect Matching Testing via Matrix Determinant 1 ...
It follows that det(B) ∕= 0. This suggests the following algorithm to determine whether G has a perfect matching.
Read more >Perfect Matching -- from Wolfram MathWorld
A perfect matching of a graph is a matching (i.e., an independent edge set) in which every vertex of the graph is incident...
Read more >Perfect game (baseball) - Wikipedia
To achieve a perfect game, a team must not allow any opposing player to reach base by any means: no hits, walks, hit...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve used that workaround too, although I would recommend using
Math.round((score * 100) / 100)
as its much slower to usetoFixed()
and then casting to `Number. Especially if there are thousands of records, it would slow it down significantly.Bump