Domain 3 of 3 · Chapter 1 of 3

Design and implement AI retrieval

Unlock the complete study guide + 25 practice exams totaling 1,500 questions.

Bundled into the existing Building AI Applications with Azure Cosmos DB premium course — no separate purchase.

14-day refund guarantee on one-time purchases and your first subscription charge.

Included in this chapter:

  • Three ways to retrieve from one container
  • Setup steps for full-text and vector search
  • Declaring full-text paths and indexes
  • How full-text analysis processes text
  • Full-text filter patterns with FullTextContains
  • Ranking by relevance with FullTextScore
  • Setting up vector search on a container
  • Sizing vectors: dimensions and precision
  • Choosing a vector index type
  • Partitioning a container for vector search
  • Sharding DiskANN with vectorIndexShardKey
  • Querying vectors with VectorDistance
  • Combining rankings with hybrid search
  • Optimizing full-text and vector performance
  • How RAG uses Azure Cosmos DB for retrieval
  • Preparing grounding chunks
  • Embedding chunks and queries consistently
  • Improving retrieval queries for RAG
  • Evaluating retrieval and generated answers
  • Recognizing retrieval scenarios in exam questions

Vector index types: flat vs quantizedFlat vs diskANN

CharacteristicflatquantizedFlatdiskANN
How a search runsBrute force over full vectorsBrute force over quantized (compressed) vectorsApproximate nearest neighbor (ANN) search
Recall100%, guaranteed exactMay be slightly below 100%, from quantizationHigh but not guaranteed; tunable per query
Maximum dimensions5054,0964,096
Recommended search scopeSmall, focused searches50,000 vectors or fewerMore than 50,000 vectors
Minimum indexed vectorsNo minimum stated1,000, otherwise a full scan1,000, otherwise a full scan
Optional build settingsNonequantizationByteSize, quantizerTypequantizationByteSize, quantizerType, indexingSearchListSize, vectorIndexShardKey

Decision tree

Need exact(100%) recall?YesNo505 or fewerdimensions?Yesflat(100% recall)Noflat is limited to505 dimensions:no exact index typeMore than 50,000vectors in onesearch scope?NoquantizedFlat(compressed)YesEvery searchfilters on onetenant or category?YesNodiskANN withvectorIndexShardKeydiskANN(approximate, ANN)Always: quantizedFlat and diskANNneed 1,000+ indexed vectors

Cheat sheet

  • Efficient full-text retrieval needs matching policy and index paths
  • Full-text analysis follows the language configured for the text path
  • English stopwords are removed during both indexing and search
  • Full-text matching uses linguistic tokens rather than raw character equality
  • Additional full-text languages require the multilingual preview feature
  • Fuzzy full-text predicates tolerate at most two edits
  • Full-text array paths have conflicting documentation
  • FullTextContains filters documents by a lexical term or phrase
  • FullTextContainsAll requires every supplied term without requiring adjacency
  • FullTextContainsAny expresses alternative acceptable lexical matches
  • FullTextScore ranks by BM25 and is not a projected score column
  • Required text matches and relevance preferences can use different terms
  • A full-text prefilter can narrow a subsequent literal substring check
  • Splitting a long BM25 search phrase can reduce query cost
  • Search facets are aggregations over the full-text matching set
  • FullTextScore is not supported in queries that use JOIN
  • Full-text query cost depends on selectivity and indexed workload size
  • Vector indexing starts with enabling the account's NoSQL vector feature
  • Each vector path declares the embedding length expected at that path
  • Vector element precision trades storage against retrieval fidelity
  • Vector similarity can use cosine, dot product, or Euclidean distance
  • Different embedding properties can have independent vector policies
  • Vector policies do not support wildcard paths or vectors nested inside arrays
  • Container vector feature enablement is not reversible
  • The application generates embeddings before storing searchable vector properties
  • Embedding dimensionality trades retrieval quality against storage and comparison cost
  • Dimensionality reduction can shrink embeddings after generation
  • The flat vector index provides exact search within a 505-dimension limit
  • QuantizedFlat suits smaller searches over compressed vectors
  • DiskANN favors efficient approximate search over large candidate sets
  • QuantizedFlat and DiskANN fall back to scanning below 1000 indexed vectors
  • Vector indexing is not supported with shared throughput
  • The vector index quantizer can be product or spherical
  • VectorIndexShardKey partitions the DiskANN index by an item property
  • Omitting the shard key creates one DiskANN index per physical partition
  • A shard-focused vector query filters the shard property to its target value
  • Shard DiskANN on the attribute that consistently bounds semantic retrieval
  • Vector sharding does not replace other retrieval eligibility filters
  • VectorDistance can both rank retrieval results and expose their numeric score
  • Vector retrieval queries should explicitly bound their result count with TOP
  • VectorDistance's optional Boolean selects brute-force evaluation
  • VectorDistance accepts calculation overrides in its fourth argument
  • Increasing SearchListSizeMultiplier trades query cost for DiskANN recall
  • QuantizedVectorListMultiplier adjusts the quantized candidate search list
  • FilterPriority tunes the balance between filtering and DiskANN search
  • QuantizationByteSize changes the index's compression and accuracy trade-off
  • IndexingSearchListSize trades index-build effort for DiskANN accuracy
  • Excluding raw embedding elements from ordinary indexing reduces vector write cost
  • Repeated DiskANN queries can return slightly different approximate results
  • Vector performance and recall tests need realistic model embeddings
  • Very large vector ingestion bursts can lengthen vector index build time
  • VectorDistance expects one-dimensional numeric vectors
  • Hybrid search fuses semantic and lexical rankings with RRF
  • RRF weights correspond positionally to the scoring functions
  • RRF can fuse multiple lexical relevance signals
  • RRF can combine searches across different embedding properties
  • RRF belongs in ORDER BY RANK without an ordinary secondary property sort
  • Hybrid retrieval needs both vector and full-text configuration
  • RAG supplies retrieved content to the language model at request time
  • Cosmos DB can keep grounding content and its vector representation together
  • RAG chunks should preserve a useful concept without overwhelming model limits
  • Chunk boundaries should reflect the source document's structure
  • Query and content embeddings must use the same embedding model
  • Embedding preprocessing must be consistent between queries and chunks
  • Chunk metadata supports retrieval beyond the embedding alone
  • The RAG orchestrator selects a bounded set of relevant grounding results
  • RAG answer freshness depends on the data available to retrieval
  • Evaluate retrieval quality separately from generated-answer quality
  • Choose an embedding model by its fit to the corpus and retrieval tasks
  • Chunk overlap repeats boundary text to preserve context across cuts
  • Semantic chunking groups conceptually related content using embeddings
  • Text representations make media retrievable while source links preserve access to the original
  • Translate vague retrieval queries into context-aware searches without changing intent
  • Decompose multipart questions when different parts need separate retrieval evidence
  • HyDE uses a generated hypothetical answer as the vector retrieval probe
  • A model-based reranker refines a broader retrieval set before grounding
  • Negative retrieval tests check behavior when the corpus cannot answer
  • Agentic RAG can revise retrieval decisions using intermediate evidence
  • Scanned or complex-layout grounding documents need text and layout extraction
  • Answer completeness measures whether every part of the request is addressed
  • Context utilization shows how much retrieved material contributes to an answer
  • Answer relevance measures whether the response addresses the actual question

Unlock with Premium — includes all practice exams and the complete study guide.

Also tested in

References

  1. https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/vector-search
  2. https://learn.microsoft.com/en-us/azure/cosmos-db/gen-ai/hybrid-search
  3. https://learn.microsoft.com/en-us/credentials/certifications/resources/study-guides/dp-420
  4. https://learn.microsoft.com/en-us/azure/cosmos-db/gen-ai/full-text-search
  5. https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/how-to-dotnet-vector-index-query
  6. https://learn.microsoft.com/en-us/azure/cosmos-db/index-policy
  7. https://learn.microsoft.com/en-us/rest/api/cosmos-db-resource-provider/sql-resources/create-update-sql-container?view=rest-cosmos-db-resource-provider-2025-04-15
  8. https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/query/fulltextscore
  9. https://learn.microsoft.com/en-us/azure/cosmos-db/gen-ai/full-text-search-faq
  10. https://learn.microsoft.com/en-us/azure/cosmos-db/gen-ai/stopwords
  11. https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/query/fulltextcontainsall
  12. https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/query/fulltextcontainsany
  13. https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/query/fulltextcontains
  14. https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/query/order-by-rank
  15. https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/how-to-python-vector-index-query
  16. https://learn.microsoft.com/en-us/azure/architecture/ai-ml/guide/rag/rag-generate-embeddings
  17. https://learn.microsoft.com/en-us/azure/cosmos-db/set-throughput
  18. https://learn.microsoft.com/en-us/azure/cosmos-db/gen-ai/vector-search-performance-tips
  19. https://learn.microsoft.com/en-us/azure/architecture/ai-ml/guide/rag/rag-information-retrieval
  20. https://learn.microsoft.com/en-us/azure/cosmos-db/synthetic-partition-keys
  21. https://learn.microsoft.com/en-us/azure/cosmos-db/gen-ai/sharded-diskann
  22. https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/query/vectordistance
  23. https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/query/rrf
  24. https://learn.microsoft.com/en-us/azure/cosmos-db/gen-ai/rag
  25. https://learn.microsoft.com/en-us/azure/architecture/ai-ml/guide/rag/rag-chunking-phase
  26. https://learn.microsoft.com/en-us/azure/search/vector-search-how-to-chunk-documents
  27. https://learn.microsoft.com/en-us/azure/ai-services/document-intelligence/prebuilt/layout?view=doc-intel-4.0.0
  28. https://learn.microsoft.com/en-us/azure/architecture/ai-ml/guide/rag/rag-enrichment-phase
  29. https://learn.microsoft.com/en-us/azure/architecture/ai-ml/guide/rag/rag-agentic
  30. https://learn.microsoft.com/en-us/azure/architecture/ai-ml/guide/rag/rag-llm-evaluation-phase