opendistro-for-elasticsearch / k-NN

🆕 A machine learning plugin which supports an approximate k-NN search algorithm for Open Distro.

Home Page:https://opendistro.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

igaloly opened this issue · 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
        }
      }
    }
  }
}