Cosine Similarity Script Search does not work

Similar to these un-answered and closed topics:

I am seeing the same Error on the python client when trying to reproduce cosine similarity script search on text-embeddings as explained in this blogpost:

Query (where query_vector is a list of floats of length 512):

query = {
                    "script_score": {
                        "query": {"match_all": {}},
                        "script": {
                            "source": "cosineSimilarity(params.query_vector, doc['my_dense_vector']) + 1.0",
                            "params": {"query_vector": query_vector}
                        }
                    }}

Request:

res = es.search(index=INDEX_NAME, body={"size": QUERY_SIZE,"query": query})

Error:

RequestError: RequestError(400, 'search_phase_execution_exception', 'runtime error')

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.