Key takeaway
Replay two ranked lists and compute rank contributions for shared documents.
On this page
When keyword and semantic search each return useful passages, you need a rule to merge the lists. Reciprocal rank fusion gives each candidate credit for its position in each list. This lets you work with ranks when the underlying score scales are different. For a document at position r in a list, the contribution is 1 / (k + r). Positions start at 1. Elastic reciprocal rank fusion reference
Replay two saved lists
Save the rank fusion script and ranking fixture. These authored lists represent two result streams for a support question. No search service is required to reproduce the calculation.
python fuse-retrieval-ranks.py retrieval-rankings.json --constant 60
On November 12, 2026, the script ranked export-recovery first at 0.032258. Both lists place it second, giving it two contributions of 1/62. The individual first-place candidates each appear once, so their scores are 1/61, or 0.016393. The script breaks exact score ties by document ID for stable output.
Make IDs represent the same passage
Use the same stable ID when both systems retrieve the same record. If one list identifies a whole document and the other identifies one paragraph, choose a consistent unit before merging. Otherwise a passage and its parent could take separate slots while offering nearly the same evidence.
The script rejects duplicate IDs within a list. A retriever returning the same record twice would otherwise give it extra credit. A record appearing once in each of two lists gets both contributions as intended.
Verify fusion on a held-out set
Compare keyword-only, semantic-only and fused ranks on the same labeled questions. Record whether the expected passage appears in the first few results, and inspect misses. Agreement can also promote a wrong passage. In this fixture, if your expected passage were error-index, the fused first result would be wrong even though the calculation is correct.
Keep candidate depth and the number of passages sent to the answer model explicit. Vary one setting at a time on development examples, then check the selected setup on questions you did not tune. For a baseline that can actually run keyword search on a small corpus, start with the SQLite retrieval check.
Sources & references
Written by Modelrovia Editorial. Our standards distinguish official claims from observed results.
How we research and test →

