Loading...
const merged = [...keywordHits, ...vectorHits]
.sort((a, b) => b.score - a.score);const scores = new Map();
for (const hits of [keywordHits, vectorHits]) {
hits.forEach((hit, rank) => {
scores.set(hit.id, (scores.get(hit.id) ?? 0) + 1 / (60 + rank + 1));
});
}
const merged = [...scores].sort((a, b) => b[1] - a[1]);Reciprocal rank fusion merges by rank, so keyword and vector scores on different scales do not distort the order.
A way to merge ranked lists by adding '1 / (k + rank)' for each list a result appears in, with 'k' often set to 60. It uses ranks, not raw scores.
When queries mix meaning with exact terms like names, IDs, error codes or rare words.
Not necessarily. Many search engines and databases support full-text and vector search in one index.