# Hybrid search in one ranking

Published 2026-07-14 · Topics: Vector search, RAG

Merging keyword and embedding results without one drowning the other.

Keyword search finds the exact terms, product codes and names; embeddings find the paraphrases. A hybrid search runs both and has to turn two rankings into one.

## Scores do not mix

A keyword score and a cosine similarity live on different scales, and their distributions change with every query. Adding them, even with weights, lets whichever has the wider spread decide the result.

## Ranks do

Reciprocal rank fusion ignores the scores and uses only the positions: each list gives every document a share that shrinks with its rank, and the shares are summed.

```go
func Fuse(rankings [][]string, k float64) map[string]float64 {
	fused := map[string]float64{}
	for _, ranking := range rankings {
		for rank, id := range ranking {
			fused[id] += 1 / (k + float64(rank+1))
		}
	}
	return fused
}
```

The constant `k` flattens the curve: the larger it is, the less the very top positions dominate.

## What it does not fix

Fusion cannot recover a document that neither list returned. If recall is the problem, it has to be fixed in the retrievers themselves, before the fusion.

[All articles](https://danielealbano.me/blog)

## Building something with RAG, search or AI? Write to me.

[Open the contact form](https://danielealbano.me/contact)

---

Every page of this site is available in Markdown: request its URL with the header `Accept: text/markdown`.
