Error cosine similarity

Hello, I have created a field der type dense_vector, I have reindexed the database and when performing a search it gives me an error, as you can only have a single dense_vector value per document, I have added it as "nested", a document can have several patterns.
I don't know if I have to initialize the field in the structure to have null value in all documents or what.

The Elasticsearch version is 7.5.2.

This is the definition of the field I have created:

  • "patrones": {
    • "type": "nested",
    • "properties": {
      • "posicion": {
        • "type": "text",
        • "fields": {
          • "keyword": {
            • "ignore_above": 256,
            • "type": "keyword"}}},
      • "patron": {
        • "dims": 128,
        • "type": "dense_vector"}}},

{
"error": {
"root_cause": [
{
"type": "class_cast_exception",
"reason": "class_cast_exception: Cannot cast from [java.lang.String] to [org.elasticsearch.xpack.vectors.query.VectorScriptDocValues.DenseVectorScriptDocValues]."
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "sgaafdu-2021-1",
"node": "st2-jHV0TLyRQCSjfKJNHg",
"reason": {
"type": "query_shard_exception",
"reason": "script_score: the script could not be loaded",
"index_uuid": "K2F9Wd85TI6pp1I1X63IDg",
"index": "sgaafdu-2021-1",
"caused_by": {
"type": "script_exception",
"reason": "compile error",
"script_stack": [
"... ity(params.query_vector, 'patrones.patron') + 1.0",
" ^---- HERE"
],
"script": "100 * cosineSimilarity(params.query_vector, 'patrones.patron') + 1.0",
"lang": "painless",
"caused_by": {
"type": "class_cast_exception",
"reason": "class_cast_exception: Cannot cast from [java.lang.String] to [org.elasticsearch.xpack.vectors.query.VectorScriptDocValues.DenseVectorScriptDocValues]."
}
}
}
}
],
"caused_by": {
"type": "class_cast_exception",
"reason": "class_cast_exception: Cannot cast from [java.lang.String] to [org.elasticsearch.xpack.vectors.query.VectorScriptDocValues.DenseVectorScriptDocValues]."
}
},
"status": 400
}

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