Q7 Cosmos DB Domain 2 · 25–30% of exam Priority · Real Exam

You store 1536-dimension embeddings in Cosmos DB NoSQL and need the 5 nearest neighbours to a query vector. Which query shape is correct?

  1. A SELECT TOP 5 c.id FROM c ORDER BY VectorDistance(c.embedding, @q) (correct answer)
  2. B SELECT TOP 5 c.id FROM c WHERE ARRAY_CONTAINS(c.embedding, @q)
  3. C SELECT TOP 5 c.id FROM c ORDER BY c.embedding
  4. D SELECT TOP 5 c.id FROM c WHERE ST_DISTANCE(c.embedding, @q) < 1

Shortcut: VectorDistance() computes similarity between a stored vector and a query vector. Combining it with ORDER BY and TOP performs the k-nearest-neighbour search; the container must also have a vector index defined.