[RFC] Score per match indicesSee original GitHub issue
A score for each match indices pair would be helpful. A really long piece of text could have many matches, but only a few close ones. For example, a search engine application might want to display and highlight a snippet of the matched text for the user, but if the text is very large and there are many matches it is impossible to decide which snippet to display.
Describe the solution you’d like
An additional array property on
indicesScores. The length of the array would be the same as the indices array, each value would be a score of how closely the text in that index pair matched. It would then be possible to determine the best index pair match out of the indices array. For example, consider the following match result:
This would indicate that the indices pair at index 1 (so
[100, 104]) had the strongest match, and hence the snippet of text at that location could be displayed and highlighted.
Describe alternatives you’ve considered
My current implementation just chooses first matched indices pair to display, which sometimes ends up looking a little funny. A possible workaround would be to take each indices pair and run that substring through Fuse again to see their individual scores, but that sounds like a lot of unneeded reptition.
Love the library, thanks so much for all your amazing work! ❤️
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top GitHub Comments
This would indeed be a great feature, as currently finding the good matches is quite impossible. In my application (showing where a query matches a description) there are a lot of single letters returned. Would it be possible to add a native implementation? @krisk
@krisk This seems to be marked completed, is there any way to find the score of each index?
Perhaps an alternate and more viable option would be to turn on a boolean value like say
score property is calculated as the minimum for a particular term across all the Indices. As @KevinShiCA mentions, the
score is a value of relevancy and an
Indice Difference need not corelate.