When matching a list of strings that are longer than the query string, there is no difference between the scores of the results if differences only exist beyond the last index of the query string.
Version
6.0.0
Is this a regression?
No, I believe it existed in previous versions.
🔬Minimal Reproduction
Consider this very basic example to illustrate what I mean.
List of Items to search through:
let list = [
"mr. h",
"mr. p",
"mr. m"
];
Search Term:
let searchTerm = "mr.h"
Notice that the search term is almost equivalent to the first result- the only difference is the missing space after the ".".
Running the search produces the following results:
const options = {
includeScore: true,
threshold: 0.7,
};
const fuse = new Fuse(list, options)
const result = fuse.search(searchTerm)
I would expect the first item "mr. h" to have a higher score than the other 2, since it has only 1 character difference compared to the search query, while the others have two differences. However, all 3 scores are equal. ie. All three results have an extra space at index 2 (compared to the query), but the 2nd/3rd result also have the wrong last character (p/m instead of h).
This behaviour only seems to be present when the list items are longer than the search query, and are identical up to the length of the search query, but have differences beyond that.
Is this expected behaviour? If so, could you explain why that's the case?
Describe the bug
When matching a list of strings that are longer than the query string, there is no difference between the scores of the results if differences only exist beyond the last index of the query string.
Version
6.0.0
Is this a regression?
No, I believe it existed in previous versions.
🔬Minimal Reproduction
Consider this very basic example to illustrate what I mean.
List of Items to search through:
Search Term:
let searchTerm = "mr.h"
Notice that the search term is almost equivalent to the first result- the only difference is the missing space after the ".".
Running the search produces the following results:
I would expect the first item "mr. h" to have a higher score than the other 2, since it has only 1 character difference compared to the search query, while the others have two differences. However, all 3 scores are equal. ie. All three results have an extra space at index 2 (compared to the query), but the 2nd/3rd result also have the wrong last character (p/m instead of h).
This behaviour only seems to be present when the list items are longer than the search query, and are identical up to the length of the search query, but have differences beyond that.
Is this expected behaviour? If so, could you explain why that's the case?