opendistro-for-elasticsearch / k-NN

🆕 A machine learning plugin which supports an approximate k-NN search algorithm for Open Distro.
https://opendistro.github.io/
Apache License 2.0
277 stars 55 forks source link

Support ANN search by ID #341

Open jmazanec15 opened 3 years ago

jmazanec15 commented 3 years ago

Related issue: https://github.com/opendistro/for-elasticsearch-docs/issues/467:

In the docs it is specified that the knn query can be used to search nearest neighbours.

GET my-knn-index-1/_search
{
  "size": 2,
  "query": {
    "knn": {
      "my_vector2": {
        "vector": [2, 3, 5, 6],
        "k": 2
      }
    }
  }
}

The dimensionality of the data is approximately 1300 embeddings. I was wondering if it is possible to query knn results by passing the id of the ES document instead of the whole vector?

Currently, we do not support this. However, it is an interesting use case. We would need to have a step in the query pipeline where we get the vector based on the id and then pass it on to the rest of the query logic