diagram.mmd — flowchart
Ranking Algorithm Pipeline flowchart diagram

A ranking algorithm pipeline determines the order in which search results are presented to the user — transforming a set of candidate documents that match the query into a single ordered list that maximizes relevance and user satisfaction.

How the ranking pipeline works

Candidate retrieval produces an initial set of documents that satisfy the query's boolean constraints. This phase optimizes for recall: it would rather return too many candidates than miss a relevant result. In a typical architecture, each shard returns its local top-K documents, and the coordinator merges them into a global candidate pool.

First-stage scoring applies a fast lexical relevance model, most commonly BM25 (Best Match 25). BM25 scores each document based on the term frequency of query tokens in the document, inverse document frequency across the corpus, and a document length normalization factor. The result is a rough relevance signal computed without any expensive feature extraction.

Feature extraction computes a richer set of signals for each candidate: query-document term overlap beyond BM25, PageRank or domain authority, document freshness (recency of last modification), URL and title match strength, click-through rate history for this query-document pair, and optional dense vector similarity from a semantic embedding model.

Learning-to-rank (LTR) model combines the extracted features using a trained model — a gradient-boosted tree (LambdaMART), a neural point-wise scorer, or a cross-encoder — to produce a final relevance score. LTR models are trained offline on human relevance judgments or click logs and updated periodically.

Personalization and diversity applies post-model adjustments: boosting results matching the user's historical preferences, demoting duplicate or near-duplicate URLs, enforcing category diversity so the top 10 results span multiple content types, and applying business rules like promoted listings or safe-search filters.

Final ranked list is returned to the Search Query Processing merge step. Quality is measured through A/B testing on click-through rate, dwell time, and explicit relevance feedback collected by the Search Relevance Feedback loop.

Free online editor
Edit this diagram in Graphlet
Fork, modify, and export to SVG or PNG. No sign-up required.
Open in Graphlet →

Frequently asked questions

A search ranking pipeline is a multi-stage process that converts a set of candidate documents into a single ordered list. It typically moves from fast lexical scoring (BM25) through feature extraction and a learning-to-rank model, finally applying personalization and business rules before returning results.
BM25 scores each document for a query by computing term frequency in the document, inverse document frequency across the corpus, and a document length normalization factor. It rewards documents where query terms appear often but penalizes unusually long documents that naturally contain more terms, producing a balanced relevance signal without requiring model training.
BM25 alone works well for small corpora or when training data is unavailable. A learning-to-rank model becomes worthwhile when you have sufficient click-log or human judgment data and want to combine dozens of signals — freshness, PageRank, click-through rate, semantic similarity — that BM25 cannot incorporate.
Typical mistakes include training an LTR model without correcting for position bias in click data, applying personalization before global diversity enforcement (causing filter-bubble results), and skipping A/B testing so that a degraded model silently ships to production without detection.
TF-IDF is the earlier formulation: it multiplies a term frequency score by an inverse document frequency weight with no length normalization. BM25 is a probabilistic refinement that adds a saturation function to term frequency (preventing a term appearing 100 times from scoring 100× a term appearing once) and a document length normalization factor, making it considerably more robust in practice.
mermaid
flowchart TD Candidates[Candidate documents\nfrom index shards] --> BM25[First-stage scoring\nBM25 lexical relevance] BM25 --> Features[Feature extraction\nterm overlap, freshness, CTR] Features --> Authority[Domain authority\nand PageRank signals] Authority --> Embedding[Dense vector similarity\nsemantic score] Embedding --> LTR[Learning-to-rank model\nLambdaMART or neural scorer] LTR --> Score[Combined relevance score\nper document] Score --> Personalize[Apply personalization\nuser preference boost] Personalize --> BusinessRules[Apply business rules\npromoted listings, safe search] BusinessRules --> Diversity[Diversity penalty\nde-duplicate similar URLs] Diversity --> FinalList[Final ranked result list] FinalList --> Eval{Meets quality\nthreshold?} Eval -->|No| Relax[Relax query\nbroaden candidates] Relax --> Candidates Eval -->|Yes| Return[Return to query pipeline]
Copied to clipboard