Closed sully90 closed 4 years ago
This is by design. see why in the readme file:
Note for ElasticSearch 6 and 7 only: Because scores produced by the script_score function must be non-negative on elasticsearch 7, We convert the dot product score and cosine similarity score by using these simple equations: (changed dot product) = e^(original dot product) (changed cosine similarity) = ((original cosine similarity) + 1) / 2
We can use these simple equation to convert them to original score. (original dot product) = ln(changed dot product) (original cosine similarity) = (changed cosine similarity) * 2 - 1
Ah, I'm sure the README said this was just Elasticsearch 7 initially so I tried 6.8.1. Thanks for clearing this up :)
Hi there, I'm trying to use the plugin with Elasticsearch 6.8.1 but getting strange document scores when doing cosine similarity queries.
I have the following query:
Which returns the following hit:
The score returned from the plugin is
0.94501674
, however if you decode both vectors (using python code provided in the README) and compute the cosine similarity using the below function then the actual (correct) answer is0.8900337068367593
:I've tried the same with Elasticsearch 7.5.0 (and appropriate version of the plugin) and get the same result. I'm using the following Dockerfile to build/install the plugin and run Elasticsearch:
Any ideas why the score is inconsistent with the calculated value? Any help is greatly appreciated!