kNN Query incompatible with fields containing dots (.)

I am using the amazon/opendistro-for-elasticsearch:1.9.0 image, and when running a kNN query via “knn”, it only works at the root level for fields, i.e. running queries on embedding:

{
  embedding: [0.1, 0.2]
}

will work.

Meanwhile, running queries on topicA.embedding:

{
  topicA: {
    embedding: [0.1, 0.2]
  }
}

will not work.

Hi @eric.meadows,

You are right, the protocol is to use the field inside the query clause and the field is expected to be provided below to “knn” clause.

{“size” : 10,
“query”: {
“knn”: {
“my_vector”: { // field name
“vector”: [3, 4], // query vector
“k”: 2 // number of neighbors
}
}
}
}

For your use case, if i understand right, topicA is one collection of embeddings? If so you could label the vector as topicA_emebedding and use it with the “knn” query clause?

But if I want to have embeddings associated with different parts of my document, say I want one on words spoken, words typed, and description when displaying a video of a programmer doing a screen share, I cannot do typed.embedding and spoken.embedding, but instead have to use typed_embedding, and spoken_embedding, instead of having this as a normal document grouping? This feels like a bug to me.

Hi @eric.meadows,

Sorry i think i dont correctly follow you. Could you share the mappings and the exact query you would like to run? If possible also please share couple of indexing documents to reproduce at our end.