Closed lucaong closed 5 years ago
Sorry for taking a while to get to this...
Looks like a bug to me, I put together a simplified reproduction on jsfiddle.
It looks like, for some reason, that trailing characters only match if they are the same as the last character in the fuzzy string, weird! This also explains why the test is passing.
I'll dig into this a bit and come up with a fix, thanks for reporting.
Looking at q.toArray()
from @olivernn's example, I see the following output:
[ '*oo',
'*foo',
'oo',
'ofo',
'f*o',
'f*oo',
'fo',
'fo*',
'fo*o',
'foo' ]
Would I be incorrect in thinking that foo*
should be in there as well? The presence of fo*o
explains why fooo
is in the intersection, but why food
is not.
I've created a PR at #382 that I believe fixes this issue.
I've just pushed 2.3.5 which includes the fix from @hoelzro .
Performing fuzzy search seems to miss some words within the given edit distance. Here is one example (disabling stemming and all other pipeline functions to ensure that we are only observing the behavior of fuzzy search):
In the example above, I would expect the words
scienza
andcoscienzaxx
to also match, as they are at edit distance of 2 from the query termcoscienza
(two deletions or insertions at the word boundary).This is also visible if one observes the fuzzy
TokenSet
expansion for the termcoscienza
:I am not sure if this is a bug or the intended behavior of fuzzy search. In the latter case, maybe it would deserve a mention in the documentation.
Thanks again for the great work!