Hybrid Search with Reciprocal Rank Fusion
This lesson explains why hybrid search fuses by rank, how reciprocal rank fusion works and how to implement it in T-SQL.
Learning outcomes
After completing this lesson, you will be able to:
- Explain why raw scores from different methods cannot be added.
- Describe the reciprocal rank fusion formula.
- Identify the T-SQL structure of a hybrid search query.
Why fuse by rank
Full-text RANK values range from 0 to 1,000 and grow with relevance, while cosine distances range from 0 to 2 and shrink with relevance. Their scales and distributions differ by query, so adding or averaging them is meaningless. Reciprocal rank fusion (RRF) ignores the raw scores and uses only each item's position in each list, which makes lists from any method comparable.
Why not add the scores?
The RRF formula
For each item, RRF sums 1 / (k + rank) over the lists in which it appears, where rank starts at 1 and k is a constant, commonly 60. An item missing from a list contributes 0 for that list. Items are then ordered by the summed score, descending. The following table shows an example with k = 60.
| Item | Full-text rank | Vector rank | RRF score |
|---|---|---|---|
| Article 7 | 1 | 4 | 1/61 + 1/64 = 0.0320 |
| Article 3 | — | 1 | 1/61 = 0.0164 |
| Article 9 | 2 | — | 1/62 = 0.0161 |
| Article 5 | 5 | 2 | 1/65 + 1/62 = 0.0315 |
Items found by both methods rise to the top. A smaller k gives top positions more influence, a larger k flattens differences, and multiplying each term by a weight favours one method when evaluation shows it is more reliable for the data.
The following diagram computes RRF scores for four articles.

Computing RRF
Implementing hybrid search in T-SQL
The implementation ranks each method's top candidates in a CTE, combines them with a FULL OUTER JOIN so items found by only one method are kept, and computes the RRF score.
DECLARE @query nvarchar(400) = N'stove will not stay lit in wind';
DECLARE @q vector(1536) = AI_GENERATE_EMBEDDINGS(@query USE MODEL EmbeddingModel);
WITH Keyword AS (
SELECT TOP (50) ft.[KEY] AS ArticleID,
ROW_NUMBER() OVER (ORDER BY ft.[RANK] DESC) AS rnk
FROM FREETEXTTABLE(Support.Article, (Title, Body), @query) AS ft
ORDER BY ft.[RANK] DESC
), Semantic AS (
SELECT TOP (50) e.ArticleID,
ROW_NUMBER() OVER (ORDER BY VECTOR_DISTANCE('cosine', e.Embedding, @q)) AS rnk
FROM Support.ArticleEmbedding AS e
ORDER BY VECTOR_DISTANCE('cosine', e.Embedding, @q)
)
SELECT TOP (10) a.ArticleID, a.Title,
COALESCE(1.0 / (60 + k.rnk), 0) + COALESCE(1.0 / (60 + s.rnk), 0) AS rrf_score
FROM Keyword AS k
FULL OUTER JOIN Semantic AS s ON s.ArticleID = k.ArticleID
JOIN Support.Article AS a ON a.ArticleID = COALESCE(k.ArticleID, s.ArticleID)
ORDER BY rrf_score DESC;For large tables, the semantic CTE uses VECTOR_SEARCH with TOP (50) WITH APPROXIMATE in a subquery, and ROW_NUMBER is computed in an outer query, because window functions cannot be combined directly with WITH APPROXIMATE. Wrapping the logic in a stored procedure lets Data API builder, applications and RAG procedures reuse it.
Hybrid search that drops results
Items found by only one method
A developer implements hybrid search with an INNER JOIN between the keyword CTE and the vector CTE, then sums 1/(60 + rank). Articles that match only an error code, or only a paraphrase, never appear. What is wrong?
The INNER JOIN keeps only articles found by both methods. Use a FULL OUTER JOIN and COALESCE each term to 0, so articles found by one method still receive their single RRF term. Adding full-text RANK to cosine distance instead would mix incompatible scales, and increasing k does not bring back excluded rows.
With k = 60, what does an item ranked first in only one list score?
Show answer
1 / 61, about 0.0164.
Exam Tips
Remember for the exam
- RRF: sum of 1 / (k + rank), k commonly 60, rank from 1.
- Do not add raw full-text ranks to vector distances.
- FULL OUTER JOIN plus COALESCE keeps items found by only one method.
- Weights on each term favour the more reliable method.