Dynamic method [org.opensearch.knn.index.KNNVectorScriptDocValues.KNNNativeVectorScriptDocValues, getValue/0] not found

Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):

v 2.15.0

Describe the issue:

We have a knn_vector field which has double values. I would like to convert them to floats for retrieval (we use the vector values for feature generation). I was hoping to do something like this (maybe also convert float to a list)

“script_fields”: { “emb”: { “script”: {“lang”: “painless”,“source”: “doc[‘embedding’].getValue()” }}}

This fails with the title message. Looking at the code, I see getValue() method here. I see that the getValue() method is allowed So I am confused why this doesn’t work.

This works and does what I want

“script_fields”: { “emb”: { “script”: {“lang”: “painless”,“source”: “params._source[‘embedding’].stream().map(v → (float)v).collect(Collectors.toList())” }}}

but I read that accessing fields through _source is slow. Is there any way to get the values directly from the fields.

Configuration

field mapping:

  "embedding": {
    "full_name": "embedding",
    "mapping": {
      "embedding": {
        "type": "knn_vector",
        "dimension": 768,
        "method": {
          "engine": "faiss",
          "space_type": "innerproduct",
          "name": "hnsw",
          "parameters": {
            "ef_construction": 512,
            "encoder": {
              "name": "sq",
              "parameters": {}
            },
            "m": 16
          }
        }
      }
    }
  }

I tested it with latest main and it actually works. So I guess I just need to wait till AWS upgrades.

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