Lesson 2 of 5 Retrieval and Grounding Pipelines with Azure AI Search

Configuring Vector, Hybrid and Semantic Search

This lesson explains how vector search is configured, how hybrid search merges keyword and vector results, and how the semantic ranker improves relevance, since the best grounding comes from combining query types.

Learning outcomes

After completing this lesson, you will be able to:

  • Configure a vector profile with HNSW or exhaustive KNN.
  • Explain how Reciprocal Rank Fusion merges hybrid results.
  • Choose and tune a query type.

Vector search configuration

Vector search finds content by meaning rather than by shared words. An embedding model converts each chunk into a vector, a list of numbers (1,536 for text-embedding-3-small by default) in which texts with similar meanings lie close together. At query time, the question is embedded with the same model, and the search returns the chunks whose vectors are nearest to the query vector. This is why "How do I reset my password?" can find a passage titled "Recovering account access", which keyword search would miss.

Comparing a query with every stored vector becomes slow as an index grows to millions of chunks, so the index configuration chooses how the nearest vectors are found. A vector field's profile names an algorithm. HNSW (Hierarchical Navigable Small World) builds a graph for fast approximate nearest neighbour search, with parameters such as m and efConstruction that trade index size and build time against recall, and efSearch for query-time recall. Exhaustive KNN compares the query with every vector, which is exact but slow, and suits small indexes or measuring recall. Similarity metrics include cosine, dot product and Euclidean distance; cosine is typical for OpenAI embeddings.

Vectorizers define how text queries are embedded at search time, for example with an Azure OpenAI embedding deployment through the search service's managed identity, so the application can send text. Compression with scalar or binary quantization reduces vector storage and memory, and rescoring with the original vectors recovers accuracy. Documents and queries must use the same embedding model and dimensions.

Sort into groups

HNSW or exhaustive KNN?

Exam skills 5.1.2

Choose the vector algorithm for each situation.

Log in to try this activity Interactive activities are free with an account.

Hybrid search and semantic ranking

A hybrid query contains both search text and one or more vector queries. The service runs them in parallel and merges the rankings with Reciprocal Rank Fusion (RRF), which rewards documents that rank highly in either list. The semantic ranker then rereads the top 50 results with a language model trained for relevance, assigns a reranker score from 0 to 4, and can return captions (highlighted passages) and answers. The following request body shows a hybrid query with semantic ranking and a filter.

POST {search-endpoint}/indexes/manuals/docs/search?api-version=2025-09-01
{
  "search": "error E-4471 overheating",
  "vectorQueries": [{"kind": "text", "text": "error E-4471 overheating", "fields": "content_vector", "k": 50}],
  "queryType": "semantic",
  "semanticConfiguration": "default",
  "captions": "extractive",
  "filter": "product eq 'X200'",
  "select": "chunk_id, title, content, page",
  "top": 5
}

The following diagram shows how the two rankings are fused and then reranked.

A hybrid query runs keyword and vector searches in parallel, both with the same filter. Reciprocal Rank Fusion scores each chunk as the sum of 1 divided by 60 plus its rank in each list, so chunk A, ranked first and second, leads. The semantic ranker rereads the top 50 fused results, scores them from 0 to 4 and returns captions and answers with the top results.
RRF uses only each chunk's rank in each list, not the raw scores, so a chunk that ranks well in both lists rises to the top. Azure AI Search uses 60 as the constant in the formula.
Fill in the value

Semantic ranking

Exam skills 5.1.2

Recall the numbers behind the semantic ranker.

Log in to try this activity Interactive activities are free with an account.

Choosing and tuning

Each query type has a characteristic strength and weakness. Keyword search is precise for exact terms, identifiers and names, and it is tuned with analyzers (how text is split into terms), synonym maps and scoring profiles. Vector search handles paraphrase and cross-language questions but can miss exact identifiers, and it is tuned through the embedding model, the number of neighbours k and the HNSW parameters. Hybrid search combines both strengths and is the default for RAG, and adding the semantic ranker gives the best relevance for grounding at the cost of some added latency and a separate charge.

The following table summarizes when to use each query type and the main tuning levers.

Query typeUse whenTuning levers
Keyword (simple or full Lucene)Exact terms, identifiers, filtersAnalyzers, synonym maps, scoring profiles
VectorSemantic similarity, cross-language matchingEmbedding model, k, HNSW parameters, filters
HybridDefault for RAGVector weighting, k, filters
Hybrid + semanticBest relevance for groundingSemantic configuration fields, top results

Filters can be applied before or after the vector search (pre-filtering is the default and avoids returning fewer results than requested). Scoring profiles boost fields or freshness for keyword ranking. Every change is measured with the labelled relevance query set.

Worked example

Improving relevance

A RAG application uses pure vector search over technical manuals. It answers conceptual questions well but fails on questions that contain part numbers such as "PN-88213".

Part numbers rarely have meaningful embeddings, so vector similarity misses them. Change to hybrid search (text plus vector) so that keyword matching finds the part number, and add the semantic ranker to order the merged results. Increasing k for the vector query alone would not reliably find exact identifiers.

Check yourself

How does hybrid search combine keyword and vector results?

Show answer

With Reciprocal Rank Fusion (RRF). The semantic ranker can then rerank the top 50 results.

Exam Tips

Remember for the exam

  • HNSW for approximate search at scale; exhaustive KNN for exact results on small sets.
  • Hybrid search merges keyword and vector results with RRF; the semantic ranker reranks the top 50.
  • Use the same embedding model and dimensions for documents and queries; a vectorizer embeds queries.