k-NN icon indicating copy to clipboard operation
k-NN copied to clipboard

Retreive `knn_vector` value raising an error. What's the alternative?

Open igaloly opened this issue 3 years ago • 1 comments

When I try to retrieve a value from a knn_vector, I get this error: knn vector does not support this operation.

I do not want to use _source to get the vector, because it's slow. What are my options to save vector with the ability to retrieve it values?

Mapping:

{
  "test-1": {
    "mappings": {
      "properties": {
        "vector": {
          "type": "knn_vector",
          "dimension": 768
        }
      }
    }
  }
}

Query:

{
  "size": 0,
  "aggs": {
    "vector_iter": {
      "scripted_metric": {
        ...
        "map_script": "
            for(int i = 0; i < doc['vector'].length; i++) {
                state.sumVector[i] = state.sumVector[i] + doc['vector'][i]; <---- Here's the problem
            }
        ",
        ...
        "params": {
            "vectorLength": 768
        }
      }
    }
  }
}

igaloly avatar Jun 01 '22 12:06 igaloly

@igaloly Answered here: https://github.com/opensearch-project/k-NN/issues/412

VijayanB avatar Jun 02 '22 05:06 VijayanB