Design Search Ranking
Search ranking orders search results so the most useful pages appear first. The order decides what people read, trust and click.
The ask
A search service answers a typed question with a short list of pages. The best pages must sit at the top.
Query understanding is working out what a searcher means. Spelling, word order and missing words all hide that meaning.
A query is short and vague. The same words can name a place, a product or a song.
The answer must also be fast. People leave a search box that feels slow.
Estimate the scale
The search box handles 5,000,000,000 searches a day. The volume matches the autocomplete figure, cited as taught.
5,000,000,000 รท 86,400 = 57,870 searches per second.
The index holds 50,000,000,000 pages. The size matches the crawler figure, cited as taught.
The whole answer takes about 200 milliseconds. Retrieval, ranking and page building share that budget.
Data and features
The crawler gathers pages from the web. Each page becomes a document with text, links and a crawl date.
Entity linking means matching a mention to a known thing, such as a city or an author. Indexing applies it to every document before the document enters the index.
Some ranking features describe the document. Examples are text match, link strength, freshness and language.
Other features describe the query and the person. Examples are place, language and past clicks on similar results.
Semantic search is finding pages by meaning rather than by exact words. Embeddings let a page about car repairs match a query about fixing an automobile.
High-level design
A query first passes through query understanding. Spelling is fixed, words are grouped, and mentions are linked to entities.
Retrieval searches the index for matching documents. It returns the top 1,000 documents for the query.
50,000,000,000 รท 1,000 = 50,000,000.
Retrieval narrows the index by a factor of 50,000,000 for one query. Ranking then rescores the survivors with a heavier model, and the screen shows the top 10.
5,000,000,000 ร 1,000 = 5,000,000,000,000 rescorings a day.
The heavy model runs only after retrieval has cut the field. Scoring every page with it would break the budget at once.
Training the model
Training examples come from logged searches. Each example pairs a query with a document and its outcome.
Clicks are weak labels. Position bias means top results earn clicks because they sit on top, not only because they are best.
Human judges label a sample of query and document pairs. Their labels anchor the click data.
The ranking model learns patterns that place useful documents higher. It trains on many query types, not only popular ones.
Offline tests use held-back queries. A model that wins offline still faces a live test later.
Serving predictions
Serving splits the budget across stages. Understanding and retrieval take the first share, and ranking takes the rest.
The index is sharded across many machines. Each shard returns its best matches, and the results merge into one list.
Popular queries are cached. A cached answer skips retrieval and ranking entirely.
Fresh pages enter the index through a fast path. News becomes searchable without rebuilding the whole index.
When ranking is overloaded, the service can show retrieval order alone. A plain answer beats no answer.
Deep dive: video search
Video search reuses the same retrieve-then-rank spine. Retrieval finds candidate videos, and ranking orders them for the screen.
A video has little written text of its own. Its captions carry the spoken words, and those captions act as the document text.
Titles, descriptions and channel names add more text. Retrieval matches the query against all of it.
Ranking uses watch signals. Watch time, rewatches and skips say whether a video satisfied the searcher.
A video can match the words and still fail the searcher. Weak watch signals push such videos down over time.
Evaluation and trade-offs
Offline evaluation compares two rankings on judged query sets. The better ranking puts judged useful pages higher.
Online experiments send a small share of searches to a new ranker. Clicks, fresh queries and abandonment are compared.
Speed pulls against depth. Rescoring more documents can improve the order and still break the answer budget.
Freshness pulls against stability. A fast-changing index serves news well and makes results harder to reproduce.
Personalisation pulls against privacy. Place and history improve results, and both are personal data.
Scale at a glance
| Measure | Value |
|---|---|
| Searches a day | 5,000,000,000 |
| Searches per second | 57,870 |
| Pages in the index | 50,000,000,000 |
| Answer budget | about 200 milliseconds |
Exercise
What does entity linking do before ranking?