Launch price: every exam for $29.99 a year, for the first 300 buyers. See the price

CertStreak
Menu

Optimize full-text and vector performance

A worked example

Single answer

A team is tuning vector retrieval in Azure Cosmos DB for NoSQL. Two containers are available, and both use a diskANN vector index on /embedding (1,536 dimensions). Every item has an embedding, and each evaluation query searches the entire container.

ContainerItems
development400 product items
staging200,000 product items copied from production

The team has an evaluation set of 20 queries taken from real search logs. The evaluation must meet these requirements:

  1. Request charges recorded for the indexed queries must reflect the diskANN index rather than a full scan.
  2. The team must express, as a number, the recall the approximate index gives up compared with exact nearest neighbors.
  3. The automated evaluation must not fail only because the order of results varies between runs.
  4. Brute-force vector comparisons must not run in queries that shoppers wait on.

Which evaluation approach meets all the requirements?

Choose one answer
Why

With fewer than 1,000 vectors in the search scope, DiskANN queries fall back to scanning the eligible vectors. Of the two containers, staging has enough vectors in scope for the evaluation to measure indexed request charges. A single offline brute-force run of the evaluation set, using a true third argument to VectorDistance, records the exact nearest neighbors. Counting how many of those the indexed query returns turns the recall gap into a number. Because diskANN results can be ordered slightly differently between runs, the check should test whether expected items are present rather than their order, and brute force should stay out of the shopper request path.

  • Not correct: On staging, record indexed top 10 results from a first run, then count how many of them reappear in later indexed runs. Comparing indexed runs with each other only shows run-to-run stability. With no brute-force ground truth, the recall lost by the approximate index is never measured.
  • Not correct: On staging, record brute-force top 10 results offline, then require the indexed top 10 to match them in the same order. Each replica builds its own diskANN index copy and any replica can answer, so ordering can shift slightly between runs. Requiring an identical order makes the test fail on variance alone.
  • Correct: On staging, record brute-force top 10 results offline, then count how many of them appear in the indexed top 10. Staging holds far more than 1,000 vectors, so indexed queries use the diskANN index. The offline brute-force run supplies the exact neighbors to count against, checking membership instead of order tolerates replica variance, and brute force stays out of the shopper path.
  • Not correct: On development, record brute-force top 10 results offline, then count how many of them appear in the indexed top 10. The development container has only 400 vectors, which is under the 1,000-vector threshold. Its vector queries fall back to a full scan, so the charges do not show how the index behaves.
  • Not correct: On staging, count the overlap between brute-force and indexed top 10 results offline, and record only the brute-force request charges. The overlap measures recall, but the recorded request charges reflect exact scans instead of DiskANN retrieval.

Practise this topic until it's automatic.

Ten questions a day, every answer explained, and misses that come back until you beat them.

Start free