How a Web Search Engine Answers a Query

What happens between typing a query and seeing results. Short queries and the intents behind them, query rewriting, candidate retrieval, the signals used to rank, duplicate removal, snippets, and the results page.

A web search engine answers a query in stages. It classifies the intent (navigational, informational or transactional, in Broder's 2002 taxonomy), corrects and rewrites the query, and retrieves candidates cheaply from a sharded inverted index. It then ranks them with query-dependent and query-independent signals combined by a learned model, re-ranking ever smaller sets with costlier models. Cost forces the stages: in this article's illustrative numbers, a model taking 1 millisecond per document would need over five hours for 20 million matching pages but a third of a second for 300. The top results are then deduplicated and diversified. In an invented jaguar example, maximal marginal relevance puts an animal page second whenever $\lambda < 14/17$. Logged behavior trains the next ranking.

Two queries typed into a web search engine a second apart can need entirely different treatment. The query facebook is almost certainly a request to go to one particular website, and the best result page has exactly one useful link at the top. The query best budget smartphone asks for a comparison of current products, and a page that was the best answer two years ago is now a poor one. The query barack obama biography asks for stable facts from an authoritative source, and freshness hardly matters. And the query jaguar could mean an animal or a car. How does one engine, in a few hundred milliseconds, tell these requests apart and answer each one well from an index of billions of pages? In outline, it classifies the query, rewrites it, retrieves candidates cheaply, ranks them in stages with many kinds of evidence, and checks the top results against one another before showing them.

A web search engine must recognize which kind of request it has received and retrieve candidates from that index. It must then rank them using evidence of very different kinds and return a page of results. This article follows a single query through that process. It builds on The Architecture of a Search Engine, whose four Arctic documents showed the stages on a collection small enough to compute by hand. Here we add what is specific to the web: short and ambiguous queries, an adversarial collection, and signals from links and user behavior that a closed collection does not have.

The route follows the query. First we ask who is asking and what for, since the kind of need decides the ranking. Then we follow the query as it is corrected and rewritten, and as it physically travels through a data center. Next come candidate retrieval and ranking with many signals, with the arithmetic that forces ranking into stages. Finally we assemble the results page, where duplicates are removed and jaguar gets a diverse answer, and we see how the page itself becomes evidence for the next query.

Who is asking, and what for

Short queries, quick decisions

Studies of search logs established early what web queries look like. In an analysis of about a billion search requests to AltaVista, Silverstein, Marais, Henzinger, and Moricz (1999, Tables 2, 6 and 7) found three things:

  • distinct queries averaged 2.35 terms;
  • for 85 percent of queries, only the first page of results was requested;
  • most sessions contained a single query.

Later studies of other engines found similar figures. In a sample of more than a million queries to the Excite engine, Spink, Wolfram, Jansen, and Saracevic (2001) found a mean of 2.4 terms per query, and report that most people used few terms, modified few queries and viewed few pages of results. Query lengths have grown somewhat since, especially with spoken and conversational queries, but the core pattern holds. A query is a few words, most people read only the top of the results, and the system has a single chance to get the first few results right.

Two consequences follow. First, the system must infer most of the need, because the query states little of it. Second, ranking quality at the top of the list matters far more than quality deeper down. Evaluation measures for web search, introduced in evaluation, weight the top positions heavily for this reason.

Three kinds of intent

Andrei Broder (2002) classified web queries by the need behind them:

  • Navigational queries seek a particular site the user has in mind: facebook, irs, united airlines. There is usually one correct result, and success means placing it first.
  • Informational queries seek information assumed to exist on one or more pages: how do vaccines work, causes of the 1929 crash. Several pages may serve the need, and the user may read more than one.
  • Transactional queries seek a site where something further will be done: shopping, downloading, booking, or using a service. buy running shoes and convert pdf to word are transactional.

Broder estimated the proportions from a survey of AltaVista users and from a sample of its query log. Informational queries were the largest group (an estimated 39 percent in the survey and 48 percent in the log), navigational queries made up roughly a fifth to a quarter (24.5 and 20 percent), and transactional queries about a third (an estimated 36 percent and 30 percent). The course text summarizes the three classes (Manning, Raghavan, and Schütze, 2008, §19.4.1). Rose and Levinson (2004) refined the taxonomy with subcategories, such as informational queries that ask for advice or for a list.

Example (the thesis student's query). The thesis student's query from What Information Retrieval Is, climate arctic biodiversity, is informational: no single site is the answer, and the student will want to read several sources. So the engine should fill the top of the page with several good, different documents, not one official site.

The taxonomy matters because each intent calls for a different ranking. A navigational query is served by the one official site, and showing ten different pages would be worse than showing that one at the top. An informational query is served by several good sources, often from different perspectives. A transactional query is served by pages where the action can actually be completed.

Modern engines classify queries along many more dimensions: whether a query wants fresh content, local results, images, a product, or a direct answer. These classifications decide which ranking signals carry the most weight and which kinds of results appear on the page.

Knowing the intent is half of understanding a query. The other half is reading its words correctly, which often means changing them.

Understanding the query

Before the index is consulted, the query is analyzed and often altered. The analysis begins with normalization compatible with that applied to documents, as described in the architecture article: tokenization, case folding, and a matching treatment of word variants. Web engines then go further.

Spelling correction. A large fraction of queries contain misspellings: Cucerzan and Brill (2004) put it at roughly 10 to 15 percent of the queries sent to search engines. Query logs provide the best evidence for correcting them. A misspelled query that users frequently retype in one particular corrected form reveals its own correction. Cucerzan and Brill (2004) built a spelling corrector of this kind from query logs rather than a dictionary, which also handled names and new terms that no dictionary contains. Spelling correction and phonetic matching covers the edit-distance and k-gram methods behind spelling correction.

Recognizing structure. The engine identifies phrases (new york times), named entities (people, places, products), and operators the user typed explicitly, such as quotation marks or a minus sign. Stop words need care here. Most stop words can be ignored in matching, but some queries consist mostly of them. The query the who names a band, and to be or not to be is a quotation. Dropping the stop words destroys both.

Expansion and rewriting. The engine may add terms the user did not type, such as morphological variants, synonyms (nyc and new york city), and expansions of abbreviations. Jones, Rey, Madani, and Greiner (2006) showed that query logs can also supply substitutions. When users often follow one query with another, the second is a candidate rewrite of the first. In a conversation a different rewrite is needed: a follow-up that leans on earlier turns must become a query that stands alone, as Rewriting Questions in a Conversation describes.

How visibly the engine changes the query is itself a design decision. There are three common choices:

  1. Suggest without rewriting. The original query is run and an alternative is offered ("Did you mean ...?"). This is appropriate when the engine is unsure.
  2. Rewrite with notice. The engine runs the corrected query and says so ("Showing results for ..."), with a link to run the original instead. This is appropriate when the engine is confident, as with an obvious misspelling.
  3. Rewrite silently. The engine expands or alters the query without telling the user. A query for nj tax return may also match pages that say New Jersey tax return. Silent rewriting is appropriate only when the expansion is very unlikely to change the meaning, because a user who cannot see the change cannot correct it.

Example (choosing a policy for arctic climat warmng). The second policy, rewriting with notice, fits this query. warmng matches nothing in the index, and the correction warming is one insertion away, so the engine can be confident. Running the corrected query and saying so lets the user undo it if the guess was wrong. This site's own engine does exactly that, as the architecture article traces; How This Search Works shows how its corrector picks the nearest word that some page uses.

The trade-off is the familiar one between recall and precision, applied at the scale of an entire query. Each added term or substitution finds more pages, and each risks drifting from what the user meant.

The query is now ready to be answered. Before following it into the index, it helps to see where that index physically is.

Where the query physically goes

A widely cited public account of a large engine's serving path is the one Google engineers gave in 2003 (Barroso, Dean, and Hölzle, 2003, pp. 22–24). When a user submits a query, the browser's DNS lookup is answered by a load-balancing system. It picks one of several clusters around the world, taking into account the user's distance from each and the capacity each has free. From then on the query stays inside that cluster. A hardware load balancer passes it to one of many identical web servers, which coordinates everything else and finally formats the results page.

The path of a query through a web search engine, as described by Barroso, Dean, and Hölzle (2003). DNS picks a cluster and a load balancer picks a web server. The web server then runs two phases: index servers, one pool per shard, return their best document identifiers, and document servers turn the merged top identifiers into titles, URLs and snippets. Notice that the document servers are reached only after ranking, and only for the winners; a spell checker and an ad server work on the same query in parallel.
The path of a query through a web search engine, as described by Barroso, Dean, and Hölzle (2003). DNS picks a cluster and a load balancer picks a web server. The web server then runs two phases: index servers, one pool per shard, return their best document identifiers, and document servers turn the merged top identifiers into titles, URLs and snippets. Notice that the document servers are reached only after ranking, and only for the winners; a spell checker and an ad server work on the same query in parallel.

Query execution then has two phases.

Phase one: the index servers. The index is too large for one machine, so it is split into shards. Each shard holds the complete inverted index for a random subset of the documents, and each shard is served by a pool of identical replicas. One replica of every shard receives the query, intersects the postings lists of the query words for its own documents, scores the matches, and returns its best document identifiers. The web server merges these lists into one ranking.

Phase two: the document servers. The top identifiers go to the document servers, which are sharded the same way and hold copies of the pages themselves. They fetch each page and produce its title, URL and query-specific snippet.

Meanwhile the web server has also sent the query to a spell-checking service and to an ad-serving system, and it assembles all of these into the page.

Each stage of this article maps onto that picture:

  • query understanding happens at the web server and its helper services;
  • candidate retrieval and the first rounds of scoring happen inside each index shard, close to the postings;
  • snippets are made by the document servers, after ranking, and only for the handful of results that will be shown.

The design is from 2003. Engines have since added caches, index tiers and more ranking stages, which search at scale describes. Caches pay because query popularity is heavily skewed, and Caching in Search Engines derives the hit rate a result cache can reach under a Zipf law. But the shape of sharded index lookup, merging, and then a separate pass over the winners is still the natural way to divide the work in a document-partitioned engine.

Retrieving candidates

The rewritten query is executed against the inverted index. On the web, even a precise query matches far too many pages to score carefully; a two-word query can match millions. The engine therefore first retrieves a manageable set of candidates using a fast, simple criterion, and ranks only those carefully.

A common lexical strategy treats a multi-word query as a conjunction, retrieving pages that contain all the terms, and relaxes the condition only if too few pages match. Modern engines also draw candidates from other sources, such as the rewritten forms of the query and learned representations of meaning. A candidate therefore need not contain every term the user typed. Tiered indexes and early termination, described in search at scale, keep this step fast.

The aim at this stage is high recall at low cost. It must not lose the documents that would rank highest, but it does not need to order them correctly. Ordering is the next stage's job.

Ranking with many signals

The candidates are then scored. Web ranking combines evidence of two kinds.

Query-dependent signals describe the relationship between the query and a page:

  • Text match: how well the page's words match the query, measured by functions such as TF-IDF and BM25. These are computed for the title, headings, body and URL, either separately or combined across fields as in BM25F. Matches in the title count more than matches in the body.
  • Proximity: whether the query terms appear close together, which distinguishes a page about climate policy from one that mentions climate and policy in different sections.
  • Anchor text: the words in links that point to the page. Anchor text often describes a page better than the page describes itself, because it is written by other people for readers who have not yet seen the page. A company's home page may not contain the phrase car manufacturer, but links to it often do. Brin and Page (1998, §2.2) identified anchor text as one of the main sources of Google's early quality.
  • Click history: how users responded when the page was shown for this or similar queries. As discussed in the article on relevance, clicks are biased toward higher positions, so they are useful mainly as relative evidence.

Query-independent signals describe a page regardless of the query:

  • Link-based authority, such as PageRank, which treats a link as an endorsement and rates a page highly if pages that are themselves highly rated link to it (Manning, Raghavan, and Schütze, 2008, §21.2).
  • Quality and spam indicators computed when the page is indexed. Ntoulas, Najork, Manasse, and Fetterly (2006) showed that most of the spam pages in their sample could be detected from content features alone, such as unusually repetitive text or a page stuffed with popular words.
  • Freshness, estimated from when a page was created or last substantively changed.
  • Page properties such as language, the region it targets, and whether it loads quickly and displays well on a phone.

Some signals become important only for certain queries. Freshness barely matters for barack obama biography and dominates for best budget smartphone, where a review from two years ago describes phones no longer sold. For a query about a news event, the most useful pages may be only hours old. Such pages have had little time to gather links and clicks, so the engine must recognize that a query has become newsworthy and rank with evidence of recency (Dong et al., 2010). Location matters for pizza delivery and not for pythagorean theorem.

No hand-written formula combines this many signals well across every kind of query. Web engines use learning to rank. Each candidate becomes a vector of signal values, and a model trained on human relevance judgments and on behavioral data learns how to combine them. The classical retrieval models of this course survive inside these systems as features, and BM25 computed over fields is among the strongest inputs. In the dataset that Yahoo released from its engine for a public learning-to-rank competition, each pair of query and page is described by up to 700 features (519 in one of its two sets, 596 in the other). The organizers describe one of them, a text-match score built on BM25F with a term-proximity model, as "one of the most predictive features for relevance" (Chapelle and Chang, 2011, §4.4). Features for Ranking sorts such features by whether they depend on the query, the page or both, and shows what normalizing them within each query does.

Why ranking happens in stages

Ranking is also done in stages. A cheap function scores all candidates, and progressively more expensive models re-rank smaller and smaller subsets (Wang, Lin, and Metzler, 2011). In current systems the final stages include neural models that read the query and page text together, of which the BERT re-ranker of Nogueira and Cho (2019) is the best-known early example. The scale article describes this cascade in more detail, and Multi-Stage Ranking proves the limits a first stage sets for the later ones.

The arithmetic behind the cascade is easiest to see with numbers attached. The table below follows one query through the stages. The counts are illustrative orders of magnitude chosen for the arithmetic, not figures published for any engine:

Stage Documents considered Cost per document
Pages in the index 50,000,000,000 none: never touched
Pages containing the query terms 20,000,000 a few postings entries
Candidates scored by a cheap first-stage function 100,000 a BM25-like sum over postings
Re-ranked by a learned model with hundreds of features 300 feature lookup and a model evaluation
Shown on the first page 10 snippet generation from the stored page

Each stage but the last cuts the set by a factor of a hundred or more, and each spends far more per document than the stage before.

Example (why the expensive model cannot see every match). Suppose the expensive model takes one millisecond per document. Running it on all twenty million matching pages would take twenty million milliseconds, which is 20,000 seconds, more than five hours of computation for one query. Over the 300 survivors of the earlier stages it costs a third of a second, and that work can itself be spread across machines.

The same reasoning sets the latency budget. A results page expected in about 200 milliseconds might, again for illustration, divide its time like this:

Step Milliseconds
Network, from browser to front end and back 60
Front end: parsing, spelling, query rewriting 10
Sending the query to every index shard 5
Candidate retrieval and first-stage scoring, in parallel on each shard 50
Merging the shards' results 5
Re-ranking the top few hundred 40
Snippets from the document servers 20
Assembling the page 10
Total 200

The point of such a budget is that every stage has one. A new ranking feature is judged not only by how much it improves the ranking but by whether it fits in its slot. The first-stage slot is also only as fast as the slowest shard, since the merge must wait for all of them. Search at scale treats that problem under tail latency.

A ranked list is still not a results page. The top ten must be checked against each other, and dressed for a human reader.

Assembling the results page

Removing duplicates

Much of the web is copied. The same article appears on many sites, the same page is reachable at several URLs, and mirrors reproduce entire sites. A results page that shows five copies of one article wastes four positions.

Engines detect exact duplicates with fingerprints of the page content. They detect near-duplicates with shingling (Broder, Glassman, Manasse, and Zweig, 1997; Manning, Raghavan, and Schütze, 2008, §19.6). Each page is reduced to a sample of its overlapping word sequences, and pages that share most of their sample are treated as copies. Much of this work happens at indexing time, so that clusters of copies are already known when the results page is assembled and can be collapsed to a single representative. Near-duplicate detection covers the method in detail, and web crawling covers where it fits in gathering the collection.

Diversity

Results are also checked against one another, not only against the query. For an ambiguous query such as jaguar, a ranking that places the ten most relevant pages about the car first fails every user who meant the animal. Diversification methods select each result to be both relevant and different from those already selected. This is a practical answer to the problem raised in the relevance article: a document's value depends on what the user has already seen.

Carbonell and Goldstein (1998) introduced the approach as maximal marginal relevance (MMR). Here is the idea in one sentence: score each remaining document by its relevance minus its similarity to the documents already chosen, and pick the best. Formally, at each step MMR selects the candidate $d$ that maximizes

$$\lambda\,\mathrm{sim}_1(d, q) - (1 - \lambda) \max_{d' \in S} \mathrm{sim}_2(d, d'),$$

where $q$ is the query and $S$ is the set of documents already selected. The similarity functions $\mathrm{sim}_1$ and $\mathrm{sim}_2$ need not be the same, and $\lambda$ between 0 and 1 sets the balance between relevance and novelty.

A small example shows the selection at work. Five candidates for jaguar have been retrieved: three pages about the car (car1, car2, car3) and two about the animal (cat1, cat2). Their similarities to the query, $\mathrm{sim}_1$, are 0.90, 0.85, 0.80, 0.70 and 0.60. Pages about the same sense are similar to each other ($\mathrm{sim}_2 = 0.8$) and pages about different senses are not ($\mathrm{sim}_2 = 0.1$). These numbers are invented to make the arithmetic clear. With $\lambda = 1$, MMR ignores novelty and returns car1, car2, car3: every one of the top three is about the car.

Example (MMR with $\lambda = 0.7$). With $\lambda = 0.7$, car1 is chosen first, as before, and the second page chosen is cat1. The table shows each step.

Candidate Step 1 Step 2 Step 3
car1 0.630 chosen chosen
car2 0.595 0.355 0.355
car3 0.560 0.320 0.320
cat1 0.490 0.460 chosen
cat2 0.420 0.390 0.180

Step by step:

  1. Nothing has been selected yet, so the penalty is zero and each score is $0.7 \times \mathrm{sim}_1$. car1 wins.
  2. Every remaining car page pays a penalty of $0.3 \times 0.8 = 0.24$ for its similarity to car1. The animal pages pay only $0.3 \times 0.1 = 0.03$. car2 drops to $0.595 - 0.24 = 0.355$ and cat1 to $0.49 - 0.03 = 0.46$, so cat1 is chosen.
  3. cat2 is now penalized for resembling cat1 ($0.42 - 0.24 = 0.18$), and car2 takes third place.

The result, car1, cat1, car2, gives a user who meant the animal a relevant page in second place.

The balance point can be found exactly. cat1 beats car2 at step 2 when

$$0.7\lambda - 0.1(1 - \lambda) > 0.85\lambda - 0.8(1 - \lambda).$$

Moving the penalties to the left and the relevance terms to the right gives $0.8(1 - \lambda) - 0.1(1 - \lambda) > 0.85\lambda - 0.7\lambda$, that is, $0.7(1 - \lambda) > 0.15\lambda$. Expanding the left side gives $0.7 - 0.7\lambda > 0.15\lambda$, and adding $0.7\lambda$ to both sides gives $0.7 > 0.85\lambda$, so $\lambda < 0.7/0.85 = 14/17 \approx 0.82$. Above that value the second car page is relevant enough to outweigh its redundancy. In a real engine $\lambda$ is tuned, and the similarities come from the ranking model and from document representations rather than being assigned by hand.

Snippets

The query-dependent snippets described in the architecture article are not only a convenience. Tombros and Sanderson (1998) showed that query-biased summaries let users judge relevance more accurately and quickly than fixed summaries such as the first lines of a page.

On the web they also change what a click means. A snippet that answers the question removes the need to click at all, so a query with no clicks may be a success rather than a failure. Generating snippets requires the document text. Engines typically store the text of each page, often compressed, and generate snippets only for the few results actually shown (Turpin, Tsegay, Hawking, and Williams, 2007).

A modern results page is assembled from several sources:

  • Vertical results, such as images, news, videos, maps and shopping, come from separate specialized indexes. The engine must decide which verticals the query warrants and where to place them (Arguello, Diaz, Callan, and Crespo, 2009).
  • Answers to factual questions may be displayed directly, extracted from a page or from a structured knowledge base.
  • Advertisements are retrieved and ranked by a separate system with its own auction.
  • Increasingly, the page includes a generated summary that cites retrieved pages, which is retrieval-augmented generation applied to web search.

Each of these components is itself a retrieval problem with its own index and its own ranking.

The page is now on the screen. For the engine, though, the query is not over: what the user does next is evidence.

The results become evidence

The results page is also a measurement. The engine logs the query, the ranking, and the user's behavior: which results were clicked, how long the user stayed on a page before returning, and whether they reformulated the query. A query rewritten immediately suggests the first ranking failed. A click followed by a long visit and no further search suggests success.

These logs train the spelling corrector, the query rewriter, the intent classifiers, and the ranking model itself. They also feed controlled experiments, in which a small fraction of traffic sees a modified ranker and its behavior is compared with that of users who see the current one.

The loop has hazards:

  • Position bias. Because of the bias described in the relevance article, a model trained naively on clicks learns to keep its current top results where they are. Engines counter this by correcting for position bias, by randomizing some rankings to collect unbiased evidence, and by combining behavioral data with judgments from trained human raters.
  • Manipulation. The loop creates an incentive to game it, since anyone who can fake clicks or links can influence rankings. That is why web search has always been, in part, an adversarial problem.
  • Privacy. Query logs record what people search for, which can be sensitive, so their collection and retention carry privacy obligations.

Worked problems

These problems are posed on this article's own examples: the five jaguar candidates, the illustrative cascade and the illustrative latency budget. None comes from the course text. The script worked_examples.py recomputes every number.

Problem 1 (MMR with relevance and novelty weighted equally). Run MMR on the five jaguar candidates with $\lambda = 0.5$ and give the first three selections with every score.

Solution. The selection is car1, cat1, car2, the same as for $\lambda = 0.7$, with a wider margin at step 2. Each score is $0.5\,\mathrm{sim}_1$ minus $0.5$ times the largest similarity to a page already chosen.

Candidate Step 1 Step 2 Step 3
car1 0.450 chosen chosen
car2 0.425 0.025 0.025
car3 0.400 0.000 0.000
cat1 0.350 0.300 chosen
cat2 0.300 0.250 $-0.100$
  1. Nothing is selected, so each score is $0.5\,\mathrm{sim}_1$: 0.45, 0.425, 0.40, 0.35, 0.30. car1 wins.
  2. The car pages pay $0.5 \times 0.8 = 0.4$ for resembling car1, and the animal pages pay $0.5 \times 0.1 = 0.05$. car2 falls to $0.425 - 0.4 = 0.025$, car3 to $0.40 - 0.4 = 0$, cat1 to $0.35 - 0.05 = 0.30$ and cat2 to $0.30 - 0.05 = 0.25$. cat1 wins, and at this $\lambda$ even cat2 is ahead of both remaining car pages.
  3. The largest similarity of car2 and car3 to a chosen page is still 0.8 (to car1), so their scores do not change. cat2 now resembles cat1 and pays 0.4: $0.30 - 0.4 = -0.10$. car2 wins with 0.025.

Problem 2 (the selection for every $\lambda$). Find the top three that MMR returns on this example for every $\lambda$ strictly between 0 and 1.

Solution. There are three regimes, separated at $\lambda = 14/17 \approx 0.824$ and $\lambda = 7/8 = 0.875$:

Range of $\lambda$ Top three
$0 < \lambda < 14/17$ car1, cat1, car2
$14/17 < \lambda < 7/8$ car1, car2, cat1
$7/8 < \lambda < 1$ car1, car2, car3
  • Step 1 has no penalty, so car1, with the largest $\mathrm{sim}_1$, is first for every $\lambda > 0$.
  • Step 2 is the comparison solved in the article: cat1 beats car2 exactly when $\lambda < 0.7/0.85 = 14/17$. The other two candidates never win this step. car3 has the same penalty as car2 and a lower $\mathrm{sim}_1$, and cat2 has the same penalty as cat1 and a lower $\mathrm{sim}_1$.
  • Step 3 when cat1 was second: car2 and cat2 each resemble one chosen page, so each pays $0.8(1 - \lambda)$. The penalties cancel and car2 wins on relevance, $0.85 > 0.60$, for every $\lambda$. car3 has the same penalty and less relevance than car2.
  • Step 3 when car2 was second: car3 pays $0.8(1 - \lambda)$ and cat1 pays $0.1(1 - \lambda)$; cat2 pays the same as cat1 with less relevance, so it never wins. car3 wins when $0.8\lambda - 0.8(1 - \lambda) > 0.7\lambda - 0.1(1 - \lambda)$, that is, $0.1\lambda > 0.7(1 - \lambda)$, so $0.8\lambda > 0.7$ and $\lambda > 7/8$.

So an animal page is in the top three for every $\lambda$ below $7/8$, and in second place for every $\lambda$ below $14/17$. At the two boundary values the scores tie and the result depends on how ties are broken. The script checks the table at every multiple of 0.01. These thresholds belong to this example's invented similarities and say nothing about the right $\lambda$ for a real engine.

Problem 3 (what fits in the re-ranking slot). The illustrative budget gives re-ranking 40 milliseconds for 300 documents. Find the time allowed per document. Then suppose the model takes 1 millisecond per document on one machine: find how many documents fit in the slot, and how many machines working in parallel would cover all 300.

Solution. The slot allows about 0.133 milliseconds per document; at 1 millisecond per document only 40 documents fit, and 8 machines are needed for 300.

  • $40 / 300 \approx 0.133$ milliseconds per document.
  • At 1 millisecond each, one machine scores $40/1 = 40$ documents in 40 milliseconds.
  • Covering 300 documents at 40 per machine takes $300/40 = 7.5$, so 8 machines, each scoring its share at the same time.

The article's example computed the two totals: 0.3 seconds for the 300 survivors on one machine, and $2 \times 10^{7}$ milliseconds, which is 20,000 seconds or about 5.56 hours, for all twenty million matches. Parallel hardware can close a gap of a factor of 7.5. It cannot close a gap of $2 \times 10^{7}/40 = 500{,}000$, which is why the earlier stages exist.

Problem 4 (a new feature against the budget). A proposed ranking feature adds 0.05 milliseconds per document to the re-ranking stage of Problem 3, which otherwise uses its slot exactly. Find the new page time if all 300 documents are still re-ranked, and the number of documents that can be re-ranked if the 40-millisecond slot is kept.

Solution. Re-ranking all 300 takes 55 milliseconds and the page takes 215; keeping the slot means re-ranking 218 documents instead of 300.

  • The cost per document rises from $40/300 \approx 0.1333$ to $0.1833$ milliseconds, so 300 documents take $300 \times 0.1833 = 55$ milliseconds, 15 more than the slot.
  • The page total becomes $200 - 40 + 55 = 215$ milliseconds.
  • Within 40 milliseconds, $40 / 0.1833 \approx 218.2$, so 218 documents.

The feature therefore has two prices: its own computation, and the 82 candidates that are no longer re-ranked if the time is held. Whether it is worth having depends on whether the better ordering of 218 documents outweighs never looking at the other 82, and that is settled by measurement, with the methods of evaluation.

What we have learned

A web search engine answers a query in a sequence of steps:

  1. Classify the intent and analyze the query.
  2. Correct, expand and rewrite the query, with a deliberate choice of how visible each change is.
  3. Retrieve a large candidate set cheaply from the inverted index.
  4. Score the candidates with many query-dependent and query-independent signals, combined by a learned model and refined in stages.
  5. Remove duplicates, diversify the results, and generate snippets.
  6. Assemble the page from several verticals.
  7. Log what happens so that the next ranking is better.

The classical models covered in the rest of the course appear inside this process as components. The inverted index serves step 3, term weighting and BM25 are ranking features in step 4, and evaluation methods measure the whole. The jaguar example showed that the best page is not simply the ten most relevant documents. The cascade arithmetic showed why expensive models can see only a few hundred of them.

One matter was set aside. The index servers each held a shard, and the merge waited for the slowest one, all within a 50-millisecond slot. The next article, Search at Scale, works out how an index is divided among thousands of machines, kept fresh, and answered that quickly.

References

  • Arguello, J., Diaz, F., Callan, J., and Crespo, J.-F. (2009). Sources of evidence for vertical selection. In Proceedings of SIGIR 2009, 315–322. record
  • Barroso, L. A., Dean, J., and Hölzle, U. (2003). Web search for a planet: The Google cluster architecture. IEEE Micro, 23(2), 22–28. record · 2 pages
  • Brin, S., and Page, L. (1998). The anatomy of a large-scale hypertextual Web search engine. Computer Networks and ISDN Systems, 30(1–7), 107–117. record · 4 pages
  • Broder, A. (2002). A taxonomy of web search. SIGIR Forum, 36(2), 3–10. record
  • Broder, A. Z., Glassman, S. C., Manasse, M. S., and Zweig, G. (1997). Syntactic clustering of the Web. Computer Networks and ISDN Systems, 29(8–13), 1157–1166. record · 2 pages
  • Carbonell, J., and Goldstein, J. (1998). The use of MMR, diversity-based reranking for reordering documents and producing summaries. In Proceedings of SIGIR 1998, 335–336. record · 4 pages
  • Chapelle, O., and Chang, Y. (2011). Yahoo! Learning to Rank Challenge overview. In Proceedings of the Learning to Rank Challenge, PMLR 14, 1–24. record · 7 pages
  • Cucerzan, S., and Brill, E. (2004). Spelling correction as an iterative process that exploits the collective knowledge of web users. In Proceedings of EMNLP 2004, 293–300. record
  • Dong, A., Chang, Y., Zheng, Z., Mishne, G., Bai, J., Zhang, R., Buchner, K., Liao, C., and Diaz, F. (2010). Towards recency ranking in web search. In Proceedings of WSDM 2010, 11–20. record
  • Jones, R., Rey, B., Madani, O., and Greiner, W. (2006). Generating query substitutions. In Proceedings of WWW 2006, 387–396. record · 2 pages
  • Manning, C. D., Raghavan, P., and Schütze, H. (2008). Introduction to Information Retrieval, chapters 19 and 21. Cambridge University Press. record · 102 pages
  • Nogueira, R., and Cho, K. (2019). Passage re-ranking with BERT. arXiv:1901.04085. record · 7 pages
  • Ntoulas, A., Najork, M., Manasse, M., and Fetterly, D. (2006). Detecting spam web pages through content analysis. In Proceedings of WWW 2006, 83–92. record
  • Rose, D. E., and Levinson, D. (2004). Understanding user goals in web search. In Proceedings of WWW 2004, 13–19. record
  • Silverstein, C., Marais, H., Henzinger, M., and Moricz, M. (1999). Analysis of a very large web search engine query log. SIGIR Forum, 33(1), 6–12. record · 2 pages
  • Spink, A., Wolfram, D., Jansen, B. J., and Saracevic, T. (2001). Searching the web: The public and their queries. Journal of the American Society for Information Science and Technology, 52(3), 226–234. record
  • Tombros, A., and Sanderson, M. (1998). Advantages of query biased summaries in information retrieval. In Proceedings of SIGIR 1998, 2–10. record · 2 pages
  • Turpin, A., Tsegay, Y., Hawking, D., and Williams, H. E. (2007). Fast generation of result snippets in web search. In Proceedings of SIGIR 2007, 127–134. record
  • Wang, L., Lin, J., and Metzler, D. (2011). A cascade ranking model for efficient ranked retrieval. In Proceedings of SIGIR 2011, 105–114. record · 3 pages

Reviewed: verified, 16 Nov 2026 · citations checked, 16 Nov 2026 · editorial review, 23 Nov 2026 · 15 revisions