You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You're right, the documentation is ambiguous. The entry for minimumScore says An optional value that specifies the minimum score an item must have to appear in the results, implying >=, but then says Defaults to 0, so items that don't match the full query will not be returned., implying >.
The documentation for the search() method has the clearest specification for how the minimumScore is used: Items with scores that are <= the minimumScore option (defaults to 0) are not returned, unless the query is falsy, in which case all of the items are returned, sorted alphabetically.
In practice, the difference between >= and > won't be noticeable, as scores are unlikely to be an exact float like 0.4, so you probably won't miss any expected results (and they'd be the poorest match anyway).
The obvious case is the one you point out, when minimumScore = 0. If the query is empty, minimumScore is ignored and all results are returned, as described above. So if you want all items returned, even if they don't match at all, then you'll need to set the option to -1.
I think the most common use case is not wanting non-matches in the results, which is why the code works as it does currently. If I changed the check to >=, people who wanted to filter out non-matches would have to remember to set minimumScore = 0.0001 or something.
Perhaps the solution is another option, like includeNonMatches, which would default to false. Then zero scores could be handled based on that flag, and the check on minimumScore could use >=, making the "minimum" part of the name more accurate. However, this could also lead to somewhat strange results, like { minimumScore: 0.4, includeNonMatches: true }, which would return items with score: 0 but not with score: 0.3.
Happy to take other suggestions as well. Maybe just clarifying the minimumScore docs would be simplest.
This may or may not be a bug, or perhaps an ambiguity in the documentation.
If
minimumScore = 0
, items withscore = 0
will not be returned in the result list. Setting a negative value is required.Should this be
>=
instead of>
? Or should the documentation reflect this logic?The text was updated successfully, but these errors were encountered: