The interview problem
A search service retrieves documents with a keyword engine and an embedding model. Their scores have different scales. Design a fusion step, calculate the resulting ranking, and explain how you would choose its settings. What changes when one retriever times out or returns a deeper candidate list?
Original fundamentals practice, not a reported company interview. All rankings, scores and workloads below are hypothetical. Official technical reference retrieved September 27, 2026.
1. Explain why adding scores needs a model
A keyword score and a vector similarity are not automatically probabilities of relevance. Their units, distributions and dependence on the query differ. Suppose document A has keyword score 20 and vector score 0.2, while B has scores 5 and 0.9. An unweighted sum ranks A first: 20.2 versus 5.9. Multiplying every vector score by 100 preserves the vector ranking but changes the sums to 40 versus 95, putting B first.
This does not prove that linear fusion is wrong. It proves that choosing score transformations and weights is part of the ranking model. If scores carry useful confidence information, a fitted combination can exploit it. Evaluate it on held-out queries and explicitly define missing-score behavior. A document absent from a truncated list does not necessarily have a true score of zero.
Min–max normalization is another modeling choice. For scores 100, 10 and 9, normalization over those candidates produces 1, approximately 0.01099 and 0. Dropping the first candidate changes the remaining normalized values to 1 and 0 without changing their raw scores. Specify the candidate population used for normalization and the all-equal-score convention. Query-local normalized scores are not calibrated relevance probabilities.
2. Compute reciprocal rank fusion
Reciprocal rank fusion (RRF) uses positions instead of raw scores. With one-based ranks, a positive constant c and equal branch weights, define score(d) = Σ 1/(c + rank(d)), summing only over lists containing d. The official Elastic reference documents this rule. Here c is the rank constant; K below denotes candidate depth, a separate parameter.
Take keyword ranking A, B, C and vector ranking B, D, A. With c = 60:
| Document | Keyword rank | Vector rank | Fused score |
|---|---|---|---|
| A | 1 | 3 | 1/61 + 1/63 ≈ 0.032266 |
| B | 2 | 1 | 1/62 + 1/61 ≈ 0.032522 |
| C | 3 | Absent | 1/63 ≈ 0.015873 |
| D | Absent | 2 | 1/62 ≈ 0.016129 |
The final order is B, A, D, C. An absent item contributes nothing from that branch; do not invent rank K + 1 for it. Use a deterministic secondary key for equal fused scores and a declared policy for tied scores within each child ranking. Keep one occurrence of a canonical document per branch.
RRF discards score gaps. A huge margin between the first and second keyword hits contributes the same rank difference as an almost-tie. It is robust to strictly increasing score transformations that preserve rankings and candidate membership, but not to transformations that change filtering thresholds, ties or retrieved candidates.
3. Show the effect of the rank constant
Consider two four-document lists: keyword A, C, D, B and vector E, F, G, B. A appears only at rank 1, while B appears at rank 4 in both. At c = 1, A scores 1/2 = 0.5 and B scores 2/5 = 0.4, so A wins. At c = 60, A scores 1/61 ≈ 0.016393 and B scores 2/64 = 0.03125, so B wins.
In this example B beats A when 2/(c + 4) > 1/(c + 1), which simplifies to c > 2. They tie at c = 2. A larger constant reduces the relative difference between nearby ranks, making agreement across branches more influential. This is a property of the example, not a general claim that larger constants improve relevance.
Now truncate both lists to K = 3. B disappears entirely, even though it was the winner at c = 60 with K = 4. Fusion cannot recover a document outside the union of candidates. Tune candidate depth separately from the final number of results shown. A larger depth can improve coverage while increasing retrieval, memory and reranking costs.
4. Do not mistake repeated evidence for independent support
If the same keyword list is accidentally supplied twice, A's score in the first example becomes 2/61 + 1/63 ≈ 0.048660. B becomes 2/62 + 1/61 ≈ 0.048652. A now narrowly outranks B, although no new retrieval evidence was added. Duplicate branches act as extra weight.
Query expansions, translated queries and near-identical embedding models can create the same problem less obviously. Decide whether a family of related branches should share a fixed total weight. A weighted formulation Σ wᵢ/(c + rankᵢ(d)), with nonnegative weights and contributions only from lists containing d, can express that choice, but weights need validation; branch count is not evidence quality. RRF scores are ranking utilities, not independent likelihoods or probabilities.
Define the retrieval unit before deduplication. Multiple passages from one document may be useful for reranking but can crowd a document-level result page. Map chunks and alternate copies to canonical identities using an explicit aggregation policy, such as the best passage score followed by a document cap. Summing every chunk score rewards documents merely for having more chunks.
5. Put fusion into a bounded serving pipeline
query + authorization context
↓
keyword top K vector top K
↘ ↙
canonical candidates + branch ranks
↓
fusion → top M → optional reranker → final authorized resultsApply compatible access constraints to each retrieval path and recheck authorization before exposing content. Fusion changes ranking, not permissions. Retain branch identity, ranks, candidate depth, retrieval version and timeout status in debugging traces. This makes it possible to distinguish poor fusion from a missing branch or stale index.
For two K = 200 lists with 50 shared canonical documents, the union contains 200 + 200 − 50 = 350 documents. If 20 of 25 judged relevant documents occur in that union, recall against those judgments is 80%; incomplete judgments may omit additional relevant documents. No downstream reranker operating only on those candidates can retrieve the other five. Recall at the displayed cutoff can be lower still. This does not impose an 80% ceiling on precision: a shorter list containing only relevant documents can have 100% precision.
Fuse into a hash map in work proportional to the total list lengths, then select the top M using a heap or sort the union. For this small union, readability may matter more than asymptotic optimization. Expensive reranking usually dominates: passing M = 50 documents to a reranker caps its candidate count, but may exclude relevant candidates that fusion placed lower. Bound passage length and total tokens as well; fifty long documents can cost far more than fifty short passages.
If the vector branch times out, return a declared keyword-only fallback when product requirements allow it. Record degraded status and evaluate it separately. RRF scores shrink when a branch is absent, so a fixed score threshold can reject useful fallback results. Never relabel partial fusion as a normal two-branch run or compare its scores as calibrated confidence.
6. Choose settings using relevance and operating cost
Compare each individual retriever, equal-weight RRF and a justified score-based alternative on the same held-out query set. Tune constants, weights, candidate depth and reranker budget on development data, then evaluate once on an untouched test set. Split related query variants together to avoid tuning on near-duplicates of test queries.
Measure candidate recall, ranking quality at the displayed cutoff, latency and timeout rate. Include exact identifiers, paraphrases, rare terms, multilingual queries and queries with no relevant result. Label pooled candidates from multiple systems rather than treating every unjudged item as irrelevant. Otherwise a benchmark can favor the retriever that supplied the original judging pool.
Use paired per-query comparisons and uncertainty estimates. A gain in average ranking quality can hide failures on critical identifier queries. Inspect changed rankings and record which branch supplied useful unique candidates. Online clicks also reflect position and presentation, so an observed click difference alone does not establish relevance improvement.
7. Follow-ups and self-review
Follow-ups: Is c the number of results? No, it controls rank decay. Is a higher fused score twice as relevant? No. Will adding a third retriever always help? No, it can add correlated noise or duplicate weight. Can a reranker repair missing candidate recall? Only if it is also allowed to retrieve new candidates. Should absent candidates always get zero in linear score fusion? That is an explicit imputation assumption, not a known score.
Score 0–2 each for score-scale reasoning, correct one-based RRF arithmetic, candidate-depth sensitivity, correlated-branch handling, and a fair evaluation with a documented fallback. A strong answer can explain a ranking reversal numerically rather than simply recommending hybrid search.
Sources and next steps
- Elastic: reciprocal rank fusion — rank formula and candidate-window semantics.
All numerical examples, counterexamples and pipeline decisions are original. Continue with search ranking system design for the larger retrieval and ranking architecture.
Continue your preparation
Choose a connected learning path or browse more ML fundamentals questions. Read our editorial method and attribution policy.