Replies: 3 comments 1 reply
-
Hi! I've just encountered this problem, and dove into the source code. It looks like the algorithm just... marks every single character that the pattern and text have in common? (search.js, line 117) I'm not sure if it's intentional, and I'm considering forking it to change that specific behavior, for some project I'm working on that needs fuzzy search with match highlighting. @dxp227 (or anyone else!), have you ever found a nice solution? |
Beta Was this translation helpful? Give feedback.
-
Highlighting was almost meant to be a supplemental feature, and not really core to Fuse, yet somehow made its way in there at some point in the past 😄 . The one thing to outline, in your example, is that "Old" also matches the query "soldier", since, "old" is a substring of it. The library does provide the option |
Beta Was this translation helpful? Give feedback.
-
When I had this problem, I worked around it by sorting & filtering the indices array myself, so I could only highlight the longest match. I found the pair of indices with the greatest difference, and then highlighted that. In your example, that would be |
Beta Was this translation helpful? Give feedback.
-
Hey there! This is part question, part suggestion:
For the purposes of match highlighting, it seems like it could be helpful to filter individual
matches.indicies
based on the quality of the match.Here is an example:
list.json
main.js
results
Regardless of what
threshold
is set, we get the same set ofmatches.indicies
, though clearly "soldier" is the best match available. If we highlight all these returned ranges, we get a mess.Would it be feasible to filter returned matches?
Beta Was this translation helpful? Give feedback.
All reactions