How hybrid search ranks
Hybrid search ranks the stored pages two times, and it fuses the two lists into one list:
- The words. The full-text index (SQLite FTS5) ranks the pages by BM25. These pages are the candidates, 50 by default.
- The meaning. A local model changes the question and each page into vectors. The vector store ranks the pages by the cosine of the vectors. The fusion takes the 50 nearest pages, by default.
- The fusion. Reciprocal rank fusion gives each page the sum of
1 / (k + rank)over the lists that hold it. The constantkis 60 by default.
Select a question. Then move k and the two counts, and look at the lines. A blue line is a rank of the full text, and an orange line is a rank of the vectors. Select a page to see its fused score.
The questionpizza after midnight
Forno Esempiothe page that answers
Full text: not in the list. No word of the question is on the page.
Vectors: rank 1, cosine similarity 0.656.
Fused: rank 3 of 14.
The fused score: 1 / (60 + 1) = 0.0164
- A rank of the full text that counts
- A rank of the vectors that counts
- The page that answers the question
The rankings as a table
| Fused | Page | Full text | Vectors | Score |
|---|---|---|---|---|
| 1 | Pizza stone care | 1 | 4 | 0.0320 |
| 2 | Filter FX-2207 | 2 | 8 | 0.0308 |
| 3 | Forno Esempio | none | 1 | 0.0164 |
| 4 | Late checkout | none | 2 | 0.0161 |
| 5 | Crust and crumb | none | 3 | 0.0159 |
| 6 | Panificio rye loaf | none | 5 | 0.0154 |
| 7 | Olio Esempio | none | 6 | 0.0152 |
| 8 | Bread flours | none | 7 | 0.0149 |
| 9 | Filter guide | none | 9 | 0.0145 |
| 10 | Filter FX-2270 | none | 10 | 0.0143 |
| 11 | Museum hours | none | 11 | 0.0141 |
| 12 | City archive | none | 12 | 0.0139 |
| 13 | Monday market | none | 13 | 0.0137 |
| 14 | Museum visit | none | 14 | 0.0135 |
The full-text ranks come from the index of polite-crawler 0.1.3. The vector ranks come from Xenova/bge-small-en-v1.5 through transformers.js 4.3.1, in a CI run on 2026-10-18.
Where the numbers come from
Section titled “Where the numbers come from”The fourteen pages are made up, on .example hosts. The numbers are not made up:
- The full-text ranks come from the real index of polite-crawler. A test of the site builds the index again and compares the ranks.
- The vector ranks come from a run of the real model,
Xenova/bge-small-en-v1.5through transformers.js, in CI. The workflowsearch-figure.ymlwrites the data with the model, the versions, the date and the commit. - The fusion is
fuseRanksfrom polite-crawler, compiled into this page. A test makes sure that it gives the same list as the realfindwithrank: "hybrid".
Why two lists
Section titled “Why two lists”Each list finds pages that the other list misses:
- The words find the exact text. A barcode, a product code, a name or a rare word has little meaning for a model. BM25 finds the exact text. Select “8001234567896” in the figure.
- The vectors find the meaning. A question can use different words than the page, for example “pizza” for a page about “pies”. BM25 then misses the page, and the model finds it. Select “pizza after midnight”.
- The vectors always give a ranking. A list of vectors has each page, also when no page matches well. Thus a page with a low similarity still gets a rank. The full text gives nothing when no word matches.
What k does
Section titled “What k does”Each list gives a page 1 / (k + rank). The constant k sets how much the top of a list counts:
k |
Rank 1 | Rank 2 | Rank 10 | The effect |
|---|---|---|---|---|
| 0 | 1.000 | 0.500 | 0.100 | The first place of one list decides. |
| 60 | 0.0164 | 0.0161 | 0.0143 | A page in the two lists wins over a page in one list. |
The value 60 comes from the paper that described reciprocal rank fusion (Cormack, Clarke and Büttcher, SIGIR 2009). Select “wheelchair access”, and move k from 60 to 0. The page with the ramp goes from the fourth place to the second place.
The two counts
Section titled “The two counts”The fusion takes only the first candidates pages of the full text and the first neighbors pages of the vectors. A page after the cut gets nothing from that list. The counts keep the work small in a large store:
- Each candidate of the full text that has no vectors gets them before the fusion. Thus
candidateslimits the work of the embedder in a search. - The vector search compares the question with each stored chunk.
neighborslimits the pages that it gives to the fusion.
Use it
Section titled “Use it”Hybrid search is opt-in. It needs an embedder, and embed gives vectors to the stored pages:
import { openCrawler, transformersEmbedder } from "polite-crawler";
const crawler = openCrawler({ dir: "./crawl", embedder: transformersEmbedder() });await crawler.embed({ budget: "10m" });
const hits = await crawler.find("pizza after midnight", { rank: "hybrid", fusionK: 60, candidates: 50, neighbors: 50,});Each hit has the fused score and the passage: the chunk of the page that is nearest to the question. The model stays on your computer, and its first use downloads it from the Hugging Face Hub. The library API gives each option, and the command line has embed and find --rank hybrid.