uschindler commented on PR #12281:
URL: https://github.com/apache/lucene/pull/12281#issuecomment-1586750531

   Hi,
   so this looks like 2 different issues:
   - incorrect validation of query and indexed field contents.
   - some vectors cause NaN when the cosine is calculated. I am not sure how 
this can happen, because cosine should only be NaN when the argument of the 
square root is negative or NaN. To me this indeed looks like a rounding error. 
Maybe we should guard the cosine to not allow negative numbers. This can only 
happen for special cases, so maybe `Math.abs()` is fine to work around. 
Actually the cosine should never be outside `[-1 .. 1]`.
   
   I think instead of throwing an exception (which would be crazy to the end 
user we should make sure that due to rounding errors the argument of the cosine 
cannot get negative.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to