Using http://fusejs.io/
In just about all situations, I'm finding that the 'indices returned contain pretty much the entire string.
For a very simple example, if you go to fusejs.io, and change the first object (in 'step 1' on the left) to
{
title: "so ummmmmm Old Man's War is a book about a thing",
author: {
firstName: "John",
lastName: "Scalzi"
}
},
then tick 'Include matches' (in 'step 2' in the middle)
the resulting indices matches most of the strong, including parts that are obviously way off:
"matches": [
{
"indices": [
[
0,
0
],
[
2,
2
],
[
4,
10
],
[
14,
23
]
],
"value": "so ummmmmm Old Man's War is a book about a thing",
"key": "title",
"arrayIndex": 0
}
]
whereas I'm expecting it to just return the matched part of the string, like so:
"matches": [
{
"indices": [
[
14,
23
]
],
"value": "Man's War",
"key": "title",
"arrayIndex": 0
}
]
I've tried it in my own app and seeing similar results across a large dataset. The matching itself is quite accurate - it's just the highlighting via matches[i].indices that's wrong. It seems to always match up to the matched string, and also sometimes far beyond. Am I going bonkers? Or is this just not possible with fuse.js?
Thanks!
P.S. Can someone please let me know if I'm supposed to include or not include the 'javascript' tag on a library question like this?