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

   I think I know why it happens, in both providers we calculate the cosine 
like that and when applying the sqrt it gets negative for one of those reasons:
   
https://github.com/apache/lucene/blob/ef35e6edf4d38d88603b6ca2540f53913c5d9c2d/lucene/core/src/java/org/apache/lucene/util/VectorUtilDefaultProvider.java#L105
   
   - norm1 or norm2 is negative
   - we don't cast both factors to double before multiplication, so it 
overflows the exponent of the float
   
   The other similarity functions are not affected, but we can possibly add 
some guard her by casting both floats to double before multiplying them.


-- 
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: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to