oramasearch / orama

🌌 A complete search engine and RAG pipeline in your browser, server or edge network with support for full-text, vector, and hybrid search in less than 2kb.
https://docs.orama.com
Other
8.6k stars 289 forks source link

Implement kushuh's change preventing div by zero in removeDocumentScoreParameters #789

Closed AdventureBeard closed 1 month ago

AdventureBeard commented 1 month ago

Implement @kushuh's proposed change in #766 , modifying removeDocumentScoreParameters to check for a divide by zero scenario before doing the calculation.

Sorry to snipe this change; just needed it badly, haha!

vercel[bot] commented 1 month ago

@AdventureBeard is attempting to deploy a commit to the OramaSearch Team on Vercel.

A member of the Team first needs to authorize it.

micheleriva commented 1 month ago

Hi @AdventureBeard, thanks a lot for this PR! I fear that you should either do:

index.avgFieldLength[prop] = 0;

or

delete index.avgFieldLength[prop]

otherwise it'll fail type-checking as you're assigning undefined to a number property. Probably assigning to 0 is fine.

micheleriva commented 1 month ago

Superseeded by @#792