Lesson 1 of 2 Hybrid Search and RAG Evaluation

Hybrid Search and Semantic Ranking

This lesson explains how keyword and vector search differ, how hybrid queries merge them with Reciprocal Rank Fusion, how the semantic ranker reranks results, and how hybrid search is tuned.

Learning outcomes

After completing this lesson, you will be able to:

  • Distinguish BM25 keyword search from vector search.
  • Explain Reciprocal Rank Fusion.
  • Describe the semantic ranker and its scores.
  • Identify the settings used to tune hybrid search.

Keyword and vector search compared

Keyword search (full-text search) matches query terms against an inverted index and scores documents with BM25, which rewards documents that contain the query's rare terms. It finds exact identifiers, codes, names and acronyms reliably, but misses passages that express the same meaning in different words. Vector search compares embeddings, so it finds paraphrases and related concepts, but it can miss exact strings, such as a part number, that carry little semantic meaning for the embedding model.

Keyword (BM25)
MatchesExact terms and their variants
Strong onIDs, codes, names, rare terms
Weak onDifferent wording for the same idea
Choose when Queries contain precise terms
Vector
MatchesMeaning and paraphrases
Strong onNatural language questions, synonyms
Weak onExact strings and rare identifiers
Choose when Queries describe needs in natural language

Hybrid queries and RRF

A hybrid query in Azure AI Search contains a full-text search string and one or more vectorQueries in the same request. The service runs both, then merges the ranked lists with Reciprocal Rank Fusion (RRF): each document's fused score is the sum, over the lists it appears in, of 1 divided by a constant plus its rank. Documents that rank well in both lists rise to the top; the raw scores of the two methods, which are on different scales, do not need to be compared.

POST https://SEARCH.search.windows.net/indexes/manuals/docs/search?api-version=2025-09-01
{
  "search": "torque spec XR-4471-B",
  "vectorQueries": [
    { "kind": "text", "text": "torque spec XR-4471-B", "fields": "content_vector", "k": 50 }
  ],
  "filter": "product_line eq 'XR'",
  "queryType": "semantic",
  "semanticConfiguration": "manuals-semantic",
  "top": 5,
  "select": "title, section, content"
}

A text vector query relies on the index's vectorizer to embed the query, so the application does not call the embedding model itself. The vector query's k sets how many nearest neighbours enter the fusion, and a weight on a vector query changes its influence relative to the keyword results.

The semantic ranker

RRF combines two first-stage rankings, but neither reads the query and passage together. The semantic ranker adds a second stage: it takes the top 50 results and reranks them with a cross-encoder model, derived from Microsoft Bing, that reads the query and each passage jointly and scores how well the passage answers the query. It returns a @search.rerankerScore from 0 to 4, and optionally captions (the most relevant sentences) and answers.

  • A semantic configuration on the index names the title, content and keyword fields the ranker reads.
  • The ranker reorders results; it does not find documents that the first stage missed, so first-stage recall still matters.
  • The reranker score is comparable across queries, which makes it a good basis for a minimum relevance threshold.
  • Semantic ranking adds some latency and is billed per request beyond a free allowance.

Tuning hybrid search

Hybrid search has several levers. The right settings depend on the queries and documents, so each is tuned against the evaluation set.

LeverEffect
Vector kHow many vector candidates enter fusion; higher improves recall at some cost
Vector weightGives vector results more or less influence than keyword results in RRF
Searchable fieldsWhich fields keyword search uses; titles and headings often help
Scoring profilesBoost recent documents or specific fields in keyword scoring
FiltersRestrict both searches to applicable documents
Semantic ranker and thresholdRerank the top 50 and drop results below a reranker score
Number of results passed to the modelBalances completeness of context against noise and tokens

In typical evaluations, hybrid search with semantic ranking retrieves better than either keyword or vector search alone, which is why it is a common default for production RAG on Azure AI Search.

Worked example

Names and paraphrases

An HR assistant uses vector search only. It answers questions such as "how much time off do I get when my child is born" well, but fails on questions that mention policy codes such as "HR-PL-207" or the names of specific benefit programmes. Users ask both kinds of question.

Switch to a hybrid query that runs the user's question as both a keyword search and a vector query, merged with Reciprocal Rank Fusion, so codes and programme names match exactly while paraphrased questions still match by meaning. Add the semantic ranker to rerank the top results, and confirm the improvement with retrieval metrics on both kinds of question.

Keyword search alone would fix codes but break the paraphrased questions. A larger embedding model would still treat codes as weak signals. Raising top-k would add more vector results without making exact codes match.

Check yourself

How does Reciprocal Rank Fusion combine keyword and vector results?

Show answer

It scores each document by its rank in each result list, not by the raw scores, and sums the scores, so a document that ranks well in both lists rises to the top.

Exam Tips

Remember for the exam

  • BM25 keyword search matches exact terms; vector search matches meaning.
  • Hybrid queries run both and merge them with Reciprocal Rank Fusion.
  • The semantic ranker reranks the top 50 results with a cross-encoder; reranker scores range from 0 to 4.
  • Tune vector k and weight, fields, filters and a reranker threshold against evaluation data.