-
-
Notifications
You must be signed in to change notification settings - Fork 757
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
Match indices contain ranges of partial matches #611
Comments
I've been experimenting with highlighting search results and just stumbled upon another good example. When having an indexed string value of
As a result I end up highlighting 402220 and 0000, which is obviously completely wrong because the search query doesn't even contain two zeroes, let alone four. Same happens even if I enable the |
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 |
Yeah same problem |
@krisk Would you happen to know what is going on? Experiencing similar issue… see screenshot. import fuseJs from "fuse.js"
…
const faqFuseJs = new fuseJs(sortableTopics, {
distance: Infinity,
findAllMatches: true,
includeMatches: true,
keys: ["content", "metadata.title"],
minMatchCharLength: 2,
shouldSort: true,
threshold: 0,
})
const results = faqFuseJs.search("linux")
console.log(results) I am perhaps naively expecting |
Describe the bug
When including matches in the results the
indices
array contains ranges of partial matches that shouldn't be included in the output.Version
v6.5.3
Is this a regression?
I don't think it is as there is another report from two years ago about the same issue (#505) that was automatically closed and never resolved.
🔬Minimal Reproduction
After this
results
contains the following:Note how
indices
contains[0, 1]
when it's not even a match. I'm guessing it's there because it's a partial match, however, there aren't any options available to get rid of it. Event thethreshold
of0.001
seems to be completely ignored.This behaviour renders the indices pretty much useless because they include irrelevant ranges, which I as someone in this case searching for
AAA
don't even care about.The suggestion to set
minMatchCharLength
to2
(mentioned in #505) is not really a solution because it would still behave in the exact same way scenarios like this when the irrelevant match is 2 or more characters long.Additional context
I wanted to use this functionality to highlight matches in search results but as it stands it's not possible because if the user searches for
AAA
and I'm not manually processing/filtering indices in any way thenAA
would also get highlighted confusing the user.Not knowing much about internals of this library I'd suggest to either completely remove indices or matches that are not full matches, or at least respect the threshold and not include indices that don't match the threshold.
The text was updated successfully, but these errors were encountered: