-
-
Notifications
You must be signed in to change notification settings - Fork 311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zero division when computing scores after removing all documents from an index. #766
Comments
Hi @kushuh, thank you so much for spotting this. Would you be up for opening a PR to fix this since you already fixed it locally? It would be immensely appreciated. |
No problem, I'll open it by tonight |
Very appreciated. Thanks! |
Hi @micheleriva, I tried to open the PR just now but I don't have permission to push a new branch |
@kushuh you should probably fork and open a PR! |
Fixed in #789, released in Orama |
Describe the bug
I had a weird issues where all scores would suddendly switch to
NaN
. I found the culprit after some investigation:https://github.com/askorama/orama/blob/980eb586ebaffbfc3879cf1d3d7c642e6e14c2eb/packages/orama/src/components/index.ts#L165
Basically, when removing the last document from an index,
(docsCount - 1)
becomes 0, which results in aNaN
that screws up every following update.I managed to fix the issue locally by changing the line to:
To Reproduce
Just remove all documents from an index:
Expected behavior
If I add documents again to an emptied index, scores should compute normally.
Environment Info
Affected areas
Data Insertion, Search
Additional context
Its not just when the index is empty. Even after adding back some documents, scores will remain NaN forever, as long as the index has been emptied once.
The text was updated successfully, but these errors were encountered: