You are enabling vector search on a new Cosmos DB for NoSQL container for 1,536-dimension embeddings and want fast, low-RU similarity queries. Which two steps are required or recommended? (Select TWO.)
- Exam domain
- Develop AI solutions by using Azure data management services25–30% of the exam
- Difficulty
- Hard
- In this mock
- 18 questions on this domainPractise this domain
Why the exam asks this
Objective in the exam guide: Store and retrieve embeddings and execute vector similarity search for semantic retrieval.
Vector search in Cosmos DB has specific setup rules that are easy to get wrong. The exam checks the policy, the index and the query.
Why D and E are the answers
A multiple-response question. Choose two. There is no credit for picking only some of them.
Define a container vector policy with the path, data type, dimensions and distance function, and add a vector index such as diskANN
Query with SELECT TOP N ... ORDER BY VectorDistance(c.embedding, @query)
Vector search needs a container vector policy, and a vector index lowers latency and RUs. Queries should always include TOP N, or they try to return far more results.
Remember: Vector policy plus vector index, and always TOP N with VectorDistance.
How it works
A container vector policy declares each vector path with its data type, dimensions (default 1,536) and distance function (default cosine).
Vector index types are flat (up to 505 dimensions, exact), quantizedFlat and diskANN (up to 4,096 dimensions). diskANN is generally the most performant above about 50,000 vectors.
Queries use VectorDistance in ORDER BY, always with TOP N.
Clues in the question
The words that point to the answer, and what each one tells you.
- 1,536 dimensions
- Too many for a flat index.
- Fast, low-RU queries
- A vector index and TOP N.
In detail
- Vector policies and vector indexes are set when the container is created and cannot be changed afterwards.
- Add the vector path to excludedPaths in the regular index to keep inserts cheap.
Side by side with look-alikes
| Vector index | Max dimensions | Search |
|---|---|---|
| flat | 505 | Exact |
| quantizedFlat | 4,096 | Exact over compressed vectors |
| diskANN | 4,096 | Approximate, fastest at scale |
Every option, checked
Knowing why each wrong option fails is how you rule it out on exam day.
A. Store the embeddings in the partition keyWrong
The partition key is for distribution, not vectors.
B. Use a flat index, because it supports any number of dimensionsWrongMost tempting
A flat index supports at most 505 dimensions.
Why it tempts: Flat gives exact results, so it sounds like the safe choice. But it is limited to 505 dimensions.
C. Query with ORDER BY VectorDistance but no TOP clause, to get every matchWrong
Without TOP N, the query costs more RUs and has higher latency.
D. Define a container vector policy with the path, data type, dimensions and distance function, and add a vector index such as diskANNRight
Vector search needs a container vector policy, and a vector index lowers latency and RUs. Queries should always include TOP N, or they try to return far more results.
E. Query with SELECT TOP N ... ORDER BY VectorDistance(c.embedding, @query)Right
Vector search needs a container vector policy, and a vector index lowers latency and RUs. Queries should always include TOP N, or they try to return far more results.
In practice
- Decide the vector policy up front; changing it means creating a new container.
Use case
An illustrative scenario, not a real incident.
A support bot's container uses diskANN on /embedding and returns the 5 nearest articles for about 20 RUs a query.
See how it works
flowchart LR P["Vector policy: /embedding, float32, 1536, cosine"] --> I["Vector index: diskANN"] I --> Q["SELECT TOP 5 ... ORDER BY VectorDistance(c.embedding, @q)"] Q --> R["Nearest items with scores"]
How to read this chart
- Read it in order: Vector policy: /embedding, float32, 1536, cosine, then Vector index: diskANN, then SELECT TOP 5 ... ORDER BY VectorDistance(c.embedding, @q), then Nearest items with scores.