Exam AI-200: Developing AI Cloud Solutions on Azure tests data access, query tuning, and semantic retrieval in its Azure data management domain. The official skills summary assigns this domain 30–35% of the exam. These AI-200 vector retrieval questions cover Cosmos DB queries, embedding policies, change feed processing, and PostgreSQL vector indexes.
This is the second set in our Azure AI Cloud Developer Associate AI-200 series (Questions 11-20). It follows AI-200 Questions 1-10 on container hosting and scaling. Every question is an original practice scenario mapped to the official exam objectives, not a copy of a real exam item.
Distinguish exact retrieval from approximate nearest neighbor search. For PostgreSQL, check that the vector index operator class matches the distance operator used by the query.
Question 11: Retrieve a Known Document
A Python API stores document chunks in Azure Cosmos DB for NoSQL. A request supplies both the chunk’s exact id and its partition key value. The API needs only that one item, with the least query overhead. Which SDK operation should it use?
A) Call read_item with the ID and partition key.
B) Call query_items with an ID-only SQL filter.
C) Call upsert_item with the ID and partition key.
D) Call get_container_client with the chunk ID.
👁 Reveal Answer
Correct Answer: A
Explanation: A performs a point read using the two values that identify the item within its logical partition. This avoids running a SQL query when the item address is already known. B can search by ID, but it adds unnecessary query processing and omits the partition constraint. C writes or replaces an item rather than retrieving it. D returns a container client, not the chunk stored inside the container.
Question 12: Reduce Query Fan-Out
A Cosmos DB for NoSQL container uses /tenantId as its partition key and spans many physical partitions. An API lists all documents with a specified status for one known tenant. Its current query filters only on status. Which change scopes the query to the known tenant’s partition without changing the container design?
A) Add an equality filter on the document category.
B) Add a range filter that includes several tenant IDs.
C) Add an equality filter on the requested tenant ID.
D) Add a sort expression on the document timestamp.
👁 Reveal Answer
Correct Answer: C
Explanation: C lets Cosmos DB route the query to the partition containing the requested tenant instead of checking every physical partition. Keep the status predicate as well so the query returns the required documents. A filters a non-partition property and does not provide the required routing constraint. B does not isolate the known tenant through partition-key equality. D changes result ordering, not the set of partitions that must be searched.
Reference: Query a container: in-partition and cross-partition queries
Question 13: Avoid Indexing Unused Payloads
A Cosmos DB container uses consistent indexing with /* included. Each item contains a large nested rawPayload object that changes frequently. Queries never filter or sort on its contents, but they still need indexes on other business fields. Which policy change reduces write indexing work while preserving those query indexes?
A) Exclude /* and remove every included path.
B) Include /rawPayload/* as an additional path.
C) Set the container’s indexing mode to none.
D) Exclude /rawPayload/* and keep /* included.
👁 Reveal Answer
Correct Answer: D
Explanation: D selectively removes the unused nested payload from indexing. The more specific exclusion takes precedence over the root inclusion, while other properties remain indexed. Reducing indexed paths can lower write RU consumption and latency. A removes indexes on the business fields the queries still need. B retains payload indexing rather than reducing it. C disables indexing throughout the container, which is too broad for this workload.
Reference: Indexing policies: including and excluding property paths
Question 14: Read Back a User’s Edit
A document-editing application uses one long-lived Cosmos DB SDK client to write and read an item. It must read its own successful writes within that client session. Other sessions may temporarily see older data. Which account consistency level meets the requirement without requiring strong consistency for all readers?
A) Eventual consistency.
B) Session consistency.
C) Consistent prefix consistency.
D) Strong consistency.
👁 Reveal Answer
Correct Answer: B
Explanation: B provides read-your-writes guarantees within a client session. The SDK caches session tokens from writes and uses them as a minimum version barrier for subsequent reads in the relevant partition. A does not guarantee immediate visibility of that client’s writes. C does not provide the session’s read-your-writes guarantee. D guarantees the latest committed version more broadly, but the scenario explicitly does not require that stronger account-wide choice.
Question 15: Declare the Embedding Shape
A new Cosmos DB container will store each document’s embedding in a top-level embedding property alongside its content. The selected model produces 384 floating-point values per embedding. Vector search is enabled on the account. Which container vector policy matches this data and the required cosine comparison?
A) Use /embedding, float32, 384 dimensions, and cosine.
B) Use /content, float32, 384 dimensions, and cosine.
C) Use /embedding, float32, 128 dimensions, and cosine.
D) Use /embedding, float32, 384 dimensions, and euclidean.
👁 Reveal Answer
Correct Answer: A
Explanation: A describes the actual vector location, a supported floating-point data type, the model’s output length, and the requested distance metric. The vector policy tells the database how to interpret embeddings stored in document properties. B points at document content rather than the embedding array. C declares a length that does not match the stored vectors. D matches the shape but selects a different comparison metric from the one required.
Reference: Integrated vector store: container vector policies
Question 16: Establish an Exact Retrieval Baseline
A team tests semantic retrieval over a small Cosmos DB dataset containing 256-dimensional embeddings. It needs a vector index whose search guarantees the true nearest matches, so it can measure recall of later approximate designs. Lower latency is secondary to exact recall. Which indexing choice should it use?
A) A diskANN vector index for approximate retrieval.
B) A quantizedFlat vector index for compressed retrieval.
C) A scalar range index on the document’s title property.
D) A flat vector index for exact nearest retrieval.
👁 Reveal Answer
Correct Answer: D
Explanation: D performs brute-force vector search and provides 100% recall. The scenario’s 256-dimensional vectors fit the documented flat-index dimensionality limit, making this suitable for a small exact baseline. A uses approximate nearest neighbor search and does not guarantee every true top match. B searches compressed vectors, so quantization can reduce accuracy. C indexes a scalar text property, not the embedding distance needed for semantic retrieval.
Reference: Integrated vector store: vector indexing policies
Question 17: Recover Safely from Replayed Changes
A .NET worker uses the Cosmos DB change feed processor to update a search projection when source items are inserted or updated. After a crash, it receives a change it already applied. The team must keep fault-tolerant delivery without creating duplicate projection entries. How should it handle each change?
A) Append a new projection row with a random ID each time.
B) Clear the lease container after every completed batch.
C) Apply an idempotent update keyed by the source item.
D) Assume the processor guarantees exactly-once callbacks.
👁 Reveal Answer
Correct Answer: C
Explanation: C makes repeated application of the same change safe by targeting the same projection entry rather than adding another one. The change feed processor guarantees at-least-once delivery, so handlers must tolerate replay. A creates duplicates when an event is delivered again. B discards coordination and progress state instead of solving duplicate side effects. D relies on an exactly-once guarantee the processor does not provide.
Reference: Change feed processor: delivery guarantees and lease state
Question 18: Fix an Indexable Column Definition
A developer enables the vector extension in Azure Database for PostgreSQL. A test table declares its embedding column as vector without a dimension count. Creating an HNSW index fails with an error saying the column does not have dimensions. Every stored embedding has 384 values. Which schema definition addresses this error?
A) Define the embedding column as text.
B) Define the embedding column as vector(384).
C) Define the embedding column as vector(128).
D) Define the embedding column as jsonb.
👁 Reveal Answer
Correct Answer: B
Explanation: B declares the dimension count that the vector index requires and matches the actual embeddings. A dimensioned vector column gives the index a consistent shape to work with. A stores text rather than a directly indexable pgvector value. C declares a different length from the existing 384-value embeddings. D can hold JSON data, but it does not supply the dimensioned pgvector column required by this HNSW index.
Question 19: Match the Index to the Query
A PostgreSQL retrieval API sorts a dimensioned embedding column with the cosine-distance operator <=> and returns a limited number of nearest results. Its HNSW index currently uses vector_l2_ops. The team must preserve cosine ranking while providing a matching vector index. Which index operator class should replace the current one?
A) Keep vector_l2_ops for Euclidean distance.
B) Use vector_cosine_ops for cosine distance.
C) Use vector_ip_ops for inner product.
D) Use text_ops for text ordering.
👁 Reveal Answer
Correct Answer: B
Explanation: B matches the cosine-distance operator used by the query. PostgreSQL needs the appropriate vector operator class to consider that vector index for the requested ordering; actual planner selection still depends on the query and costs. A matches Euclidean distance instead. C supports inner-product ordering rather than the required cosine operator. D describes text comparison and does not implement the embedding distance search this API performs.
Reference: Optimize pgvector performance: selecting the index access function
Question 20: Restrict Retrieval to Eligible Documents
A Python RAG application uses Azure Database for PostgreSQL through the LangChain Azure PostgreSQL vector store. Documents contain department and approval metadata. Retrieval must return only documents that both belong to the legal department and are approved. The application must enforce these conditions in retrieval, not merely ask the language model to ignore other documents. What should it configure?
A) Combine both metadata equality conditions with AndFilter.
B) Combine both metadata equality conditions with OrFilter.
C) Add the department and approval rules only to the prompt.
D) Increase the result count without adding metadata conditions.
👁 Reveal Answer
Correct Answer: A
Explanation: A applies both eligibility conditions to the vector-store similarity search. An AND combination requires each retrieved document to satisfy department and approval constraints together. B permits documents that satisfy only one condition, which is too broad. C leaves retrieval unrestricted and relies on model behavior rather than filtering the source documents. D changes how many matches are requested but does not enforce either metadata requirement.
Study Tips for Cosmos DB and PostgreSQL Retrieval
- Known item address. Use a Cosmos DB point read when you have both the item ID and its partition key value.
- Selective indexing. Exclude unused payload paths rather than disabling indexes needed by business queries.
- Recall trade-offs. Compare approximate retrieval against an exact baseline instead of assuming every index returns identical matches.
- Shape and metric. Match embedding dimensions, distance operators, and vector index operator classes before tuning compute.
Keep Practicing for Azure AI Cloud Developer
Use these AI-200 vector retrieval questions with small query and indexing labs. Revisit AI-200 Questions 1-10 for container hosting and scaling. The next set, Questions 21-30, will cover Redis caching and event processing.
