Hello ,
while doing query on my embedding field with this mapping
"keywordsEmbedding": {
"type": "dense_vector",
"dims": 1536
},
and this query :
GET /my_index/_search
{
"query": {
"script_score": {
"query": {
"bool": {
"filter": []
}
},
"script": {
"source": "cosineSimilarity(params.query_vector, doc['keywordsEmbedding'])",
"lang": "painless",
"params": {
"query_vector": [
-0.010962439,
-0.0069970214,
I ge the following error :
{
"error": {
"root_cause": [
{
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"cosineSimilarity(params.query_vector, doc['keywordsEmbedding'])",
" ^---- HERE"
],
"script": "cosineSimilarity(params.query_vector, doc['keywordsEmbedding'])",
"lang": "painless",
"position": {
"offset": 41,
"start": 0,
"end": 63
}
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "my_index",
"node": "tpn_abVVSPK-DGay7NJU8w",
"reason": {
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"cosineSimilarity(params.query_vector, doc['keywordsEmbedding'])",
" ^---- HERE"
],
"script": "cosineSimilarity(params.query_vector, doc['keywordsEmbedding'])",
"lang": "painless",
"position": {
"offset": 41,
"start": 0,
"end": 63
},
"caused_by": {
"type": "class_cast_exception",
"reason": "cannot implicitly cast def [org.elasticsearch.index.mapper.vectors.DenseVectorScriptDocValues] to java.lang.String"
}
}
}
]
},
"status": 400
}
what am I doing wrong ?
thanks !