Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

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

Open
igaloly opened this issue Jun 1, 2022 · 1 comment
Open

Comments

@igaloly
Copy link

igaloly commented Jun 1, 2022

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
        }
      }
    }
  }
}
@VijayanB
Copy link
Member

VijayanB commented Jun 2, 2022

@igaloly
Answered here: opensearch-project/k-NN#412

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants