- 5.1 Build retrieval and grounding pipelines — ingest and index, semantic/hybrid/vector search, enrichment skills, RAG ingestion with OCR, connecting retrieval to agents
- 5.2 Extract content from documents — multimodal OCR + layout + field extraction, clean grounded representations, analyzers for structured or markdown output
5.1 Build retrieval and grounding pipelines
The four Azure AI Search objects
Every indexing question comes down to which of these four you change:
| Object | Defines |
|---|---|
| Data source | Where the content lives and how to detect changes — Blob Storage, ADLS Gen2, Cosmos DB, Azure SQL, Table Storage, Microsoft OneLake |
| Index | The schema: fields, types, and per-field attributes (searchable, filterable, sortable, facetable, retrievable, key), vector fields and their profiles, semantic configuration, scoring profiles, analyzers |
| Skillset | The enrichment operations applied during indexing. At least one skill, maximum 30; three to five is typical. Supports chaining, looping and branching |
| Indexer | The driver that connects data source → skillset → index, on demand or on a schedule |
flowchart LR DS["Data source<br/>Blob · ADLS Gen2 · Cosmos DB<br/>Azure SQL · Table · OneLake"] DS --> C1["1 · Document cracking<br/>open the file, extract<br/>text and images"] C1 --> C2["2 · Field mappings<br/>source field → index field"] C2 --> C3["3 · Skillset execution<br/>OCR · layout · chunk · embed<br/>enrich · custom skills"] C3 --> C4["4 · Output field mappings<br/>enriched node → index field"] C4 --> C5["5 · Push to index"] C3 -.-> KS["Knowledge store<br/>(non-search scenarios)"] C3 -.-> CACHE["Enrichment cache<br/>(reuse expensive OCR)"]
Enrichment: built-in and custom skills
AI enrichment is image and natural-language processing inside the indexer pipeline, extracting text and structure from content that could not otherwise be indexed. The skills the exam is most likely to name:
| Skill | Does | Reach for it when |
|---|---|---|
| OCR skill | Extracts text from images and scanned pages | Scanned PDFs, photos of documents, text inside embedded images |
| Image Analysis skill | Tags, captions and visual features for images | Making image content searchable by description |
| Text Split skill | Chunks text into sentences or pages of a given length, with overlap. Free, all regions | The default chunker for long prose |
| Document Layout skill | Document Intelligence layout: headings, tables, reading order — structure-aware chunking | Documents where sections and tables carry meaning |
| Azure Content Understanding skill | Semantic, layout-aware chunking that respects paragraph boundaries | Better chunk quality than fixed-length splitting |
| Azure OpenAI Embedding skill | Generates vectors for chunks. Set dimensions to match your model | Any vector or hybrid index |
| Azure Vision multimodal embeddings skill preview | Embeds images into the same vector space as text | Searching images by text description |
| AML skill | Calls a model you deployed from the Foundry catalog | Using a catalog embedding model for integrated vectorization |
| Entity Recognition, Key Phrase, Language Detection, Text Translation, PII Detection, Sentiment | Azure Language capabilities applied during indexing | Filterable metadata: extract entities to facets, translate to one query language, redact before storage |
| Shaper skill | Reshapes enriched nodes into a complex structure | Preparing a projection for a knowledge store |
| Custom Web API skill | Calls your endpoint with the skill's input/output contract | Anything not covered by a built-in skill — a bespoke model, a lookup, business logic |
Two skillset features worth remembering
Enrichment caching preview reuses already-processed enrichments across runs — valuable when your skillset includes OCR and image analysis, which are expensive. A knowledge store persists enriched or generated content to Azure Storage as objects or tabular rowsets, for non-search scenarios like knowledge mining and data science; it is defined in the skillset but created in Storage.
Chunking and integrated vectorization
flowchart TD
D["Source document"] --> S{"Structure?"}
S -- "Long prose" --> T["Text Split skill<br/>sentences or pages,<br/>with overlap"]
S -- "Headings, tables,<br/>sections matter" --> L["Document Layout skill<br/>or Azure Content Understanding skill<br/>layout-aware chunking"]
S -- "Scanned / image-only" --> O["OCR first,<br/>then chunk"]
T --> E["Embedding skill"]
L --> E
O --> E
E --> I["Index: chunk text +<br/>vector + parent key + metadata"] Integrated vectorization extends both pipelines so you never compute embeddings yourself:
- During indexing — a chunking skill plus an embedding skill in the skillset, with vectors routed to dedicated vector fields.
- At query time — a vectorizer defined in the index and attached to vector fields through a vector profile, so you can submit plain text and the service embeds it for you.
Indexing skill vs query vectorizer
These are two different objects and the exam does separate them. An embedding skill lives in the skillset and vectorises content during indexing. A vectorizer lives in the index and vectorises the query at search time. Use the same embedding model for both — mismatched models put queries and documents in different vector spaces and retrieval quality collapses. Vector conversion is one-way: there is no vector-to-text, which is why indexes keep both vector and non-vector fields.
Vector, hybrid and semantic search
flowchart TB Q["Query string"] --> A["Full-text search<br/>BM25 over the inverted index"] Q --> B["Vector search<br/>HNSW / exhaustive KNN<br/>over embeddings"] A --> RRF["Reciprocal Rank Fusion<br/>merges the two ranked lists"] B --> RRF RRF --> SEM["Semantic ranker (L2)<br/>Bing-derived models rerank,<br/>plus captions and answers"] SEM --> TOP["Top-k grounding chunks"] RRF -.->|"semantic ranking off"| TOP
| Type | Mechanism | Strength | Weakness |
|---|---|---|---|
| Keyword / full-text | BM25 over an inverted index | Exact matches: product codes, jargon, dates, names | Misses synonyms and paraphrase |
| Vector | HNSW (approximate) or exhaustive KNN, scored by cosine, euclidean or dotProduct | Conceptual similarity with no shared keywords; multilingual | Weak on exact identifiers; needs good chunking |
| Hybrid | Both in one request, merged by RRF | Combines precision and recall — the sensible default | Scores are uniformly smaller than single-query scores |
| Semantic ranking | L2 reranking with Bing-derived deep-learning models over the BM25- or RRF-ranked result set | Best relevance; adds captions, answers and optional query rewrite | Applies to text only, and only to an initial result set |
from azure.search.documents.models import VectorizableTextQuery
# Hybrid + semantic: the benchmark-backed default for RAG grounding.
# search_text drives BM25, vector_queries drives ANN, RRF merges them,
# then the semantic ranker reorders the merged list.
results = search_client.search(
search_text="what is the parental leave allowance for contractors",
vector_queries=[
VectorizableTextQuery( # the index vectorizer embeds this for you
text="what is the parental leave allowance for contractors",
k_nearest_neighbors=50,
fields="content_vector",
)
],
query_type="semantic",
semantic_configuration_name="default",
query_caption="extractive",
query_answer="extractive",
filter="department eq 'HR' and effective_date ge 2026-01-01",
select=["chunk_id", "title", "content", "url"],
top=5,
)
for r in results:
print(r["@search.reranker_score"], r["title"]) Search facts that get tested verbatim
- RRF merges multiple ranked lists using the inverse of each result's rank. It fires whenever two or more queries run in parallel — hybrid, or several vector fields.
- Filters and semantic ranking apply to textual content only, not to vectors.
vectorFilterModedecides whether a filter runs before (preFilter) or after (postFilter) the vector search — a recall-versus-precision trade-off.- Azure OpenAI embedding models use cosine similarity; use cosine unless you have a reason not to.
- Semantic ranker adds three things: L2 reranking, captions and answers in the response, and query rewrite (up to 10 variants) when enabled.
- Hybrid retrieval with the semantic ranker is the Microsoft-benchmarked best configuration for grounding — the safe answer to "how do we improve RAG relevance?".
Agentic retrieval, knowledge sources and knowledge bases
Agentic retrieval is a multi-query pipeline for complex agent workflows. A knowledge base represents a complete domain and consists of one or more knowledge sources, an optional LLM for query planning and answer synthesis, and retrieval parameters. Each request goes through planning, decomposition into focused subqueries, parallel retrieval, semantic reranking and merging, returning a three-part response optimised for agent consumption.
- Indexed knowledge sources use the classic indexing and query engines; remote knowledge sources bypass indexing and are queried live.
- Your agent references the knowledge base for what to ground on; the knowledge base decides how to ground.
- Foundry surfaces this as Foundry IQ — a managed, permission-aware knowledge layer reusable across agents.
- A query planner breaks conversational history into subqueries; the merged documents are the grounding data the model cites.
Connecting retrieval to agents and workflows
| Route | How | Notes |
|---|---|---|
| Azure AI Search tool | Connect the search service, attach the tool, point it at an index | Returns results with inline citations. Index needs searchable/retrievable Edm.String fields and searchable Collection(Edm.Single) vector fields |
| Foundry IQ knowledge base | Connect the knowledge base to the agent | Managed, multi-source, permission-aware |
| File search tool | Upload files, create a vector store | Foundry owns ingestion; reuse a persistent store in production |
| Toolbox | Put the retrieval tool in a toolbox | Reuse across agents, centralise credentials, versioning and policy |
| Custom function or OpenAPI | Wrap your own retrieval service | When retrieval has bespoke logic |
Private networking changes the auth choice
If the Azure AI Search tool must work over a private virtual network, the connection has to use the Entra project managed identity. Key-based authentication is not supported with private networking for that tool. This is a favourite detail in security-flavoured questions.
5.2 Extract content from documents
Content Understanding: the multimodal extraction pipeline
Content Understanding combines OCR, layout analysis and generative field extraction in one service, and returns confidence scores and source grounding so a workflow can decide what to accept automatically and what to send for review. Its stages:
| Stage | What happens |
|---|---|
| Inputs | Documents, images, audio or video |
| Analyzer | The reusable definition: extraction settings, field schema and model deployments. Prebuilt or custom |
| Content extraction | OCR, selection marks, barcodes, formulas, and layout elements — paragraphs, sections, tables, reading order. For audio and video: transcription and key visual elements |
| Segmentation | enableSegment splits a file into logical sections — by document type, or a video into scenes |
| Field extraction | Structured key-value pairs from your schema, via Extract (documents only), Classify or Generate |
| Confidence scores | 0–1 per field, enabling straight-through processing. Enabled with estimateFieldSourceAndConfidence |
| Grounding | The region of the source each value came from, so a human can verify it in one click |
| Output | Markdown for search and retrieval, or JSON matching your schema for automation and analytics |
# An analyzer is a reusable definition: what to extract, how, and in what shape.
analyzer = {
"baseAnalyzerId": "prebuilt-document",
"config": {
"enableOcr": True,
"enableLayout": True, # tables, sections, reading order
"enableFigureDescription": True, # describe charts and diagrams
"estimateFieldSourceAndConfidence": True, # confidence + grounding
"tableFormat": "html",
},
"fieldSchema": {
"fields": {
"InvoiceNumber": {"type": "string", "method": "extract"},
"InvoiceDate": {"type": "date", "method": "extract"},
"VendorName": {"type": "string", "method": "extract"},
"Total": {"type": "number", "method": "extract"},
"Category": {
"type": "string",
"method": "classify",
"enum": ["goods", "services", "travel", "other"],
},
"RiskSummary": {
"type": "string",
"method": "generate",
"description": "One sentence on anything unusual about this invoice.",
},
}
},
} Classification and splitting
A single API call can classify, split and extract. The supported document scenarios are worth memorising because they map directly onto exam wording:
- Classify only — the file contains one document type; label it.
- Classify and analyze — label it, then route it to the right extraction analyzer.
- Classify and segment — one file holds several concatenated documents (a loan pack: application form, pay slip, bank statement); split it.
- Classify, segment and analyze — split, then route each segment to its own analyzer.
- Hierarchical classifier — a category can route to another classifier for a second level.
Classification needs no training dataset: you define up to 200 category names and
descriptions in the analyze operation. From the GA version you must include an other
category, or every file is forced into one of your defined categories. The minimum classification unit for documents
is a single page — intra-page classification is not supported.
Clean, grounded representations for RAG
"Produce clean, grounded representations to use with agents and RAG" is the objective that explains why Content Understanding sits in this skill area at all. A raw PDF is a bad input to a vector store; a Content Understanding markdown output is a good one, because it:
- Preserves structure — headings, sections, tables (including tables spanning multiple pages as one logical table), reading order.
- Captures figures —
enableFigureDescriptionandenableFigureAnalysisturn charts and diagrams into text that can be indexed and retrieved. Information that is otherwise invisible to search. - Detects annotations — handwritten notes, underlines, strikethroughs.
- Normalises every modality into the same shape, so audio and video land in the same index as documents.
- Carries grounding and confidence, so citations point at a real region of a real page.
The RAG ingestion flow, end to end
1. Land the source files in Blob Storage or ADLS Gen2. 2. Convert each file to a clean representation — Content Understanding markdown for anything complex, OCR for scanned images. 3. Chunk with a layout-aware chunker rather than fixed length. 4. Embed the chunks with an embedding skill. 5. Index chunk text, vector, a parent-document key and filterable metadata. 6. Query with hybrid + semantic ranking, filtered by metadata. 7. Attach the index to the agent so answers carry citations. 8. Schedule the indexer and monitor its execution history.
Content Understanding vs Document Intelligence
| Content Understanding | Document Intelligence | |
|---|---|---|
| Approach | Generative, schema-driven extraction with an LLM underneath | Trained prebuilt and custom document models |
| Modalities | Documents, images, audio and video | Documents and forms |
| Defining a schema | Describe the fields in natural language — no labelling required to start | Prebuilt models, or label a training set for custom models |
| Output | Markdown or JSON, with confidence and source grounding | Structured JSON with confidence |
| Choose it when | Mixed modalities, a bespoke schema, RAG-ready output, multi-document reasoning (pro mode) | A well-known form type with a prebuilt model, or a stable high-volume layout with a trained custom model |
Two portals, and the resource you need
Content Understanding is used from the Foundry portal (for agentic workflows, via the Content Understanding tool) and from Content Understanding Studio (for analyzer improvement through data labelling, and classification-based custom analyzers — the natural home if you are migrating from Document Intelligence). Either way you need a Foundry resource. Content Understanding also brings your own model deployments: it uses generative and embedding models you have deployed, which is why its guardrail behaviour follows that deployment's configuration.
Skill 5 rapid-fire review
- Four objects: data source, index, skillset, indexer. Skillsets allow 1–30 skills.
- Indexer stages: document cracking → field mappings → skillset → output field mappings → index.
- Embedding skill = indexing time. Vectorizer = query time. Same model for both.
- BM25 for text, HNSW or exhaustive KNN for vectors, RRF to merge, semantic ranker to rerank.
- Filters and semantic ranking are text-only.
vectorFilterModesets pre- or post-filtering. - Semantic ranker adds L2 reranking, captions and answers, and query rewrite.
- Hybrid + semantic is the best-relevance default for grounding.
- Knowledge store = enriched content persisted to Storage for non-search use. Enrichment caching = reuse expensive OCR.
- Content Understanding: Extract is documents-only; Classify and Generate work across modalities.
- Classification needs no training data, supports up to 200 categories, requires an
othercategory, and works at page granularity for documents. estimateFieldSourceAndConfidenceturns on confidence scores and grounding — the enabler for straight-through processing.- Azure AI Search tool over a private network requires managed identity, not keys.