The interview prompt

“Design the search ranking system for an online product marketplace.”

Search begins with an explicit expression of intent. Someone typing a precise model number has a different need from someone searching for “comfortable shoes.” A strong answer preserves exact matches while improving relevance for broader queries.

Assume a catalog of 10 million active listings, 1,000 peak search requests per second, a 250 ms p95 server budget, and a first page of 20 results. We will design retrieval and ranking; checkout and payment processing are out of scope. These are illustrative assumptions to negotiate.

01. Define relevance and success

Clarify whether the surface mixes products, sellers, and ads. Here, rank organic product listings only. Hard constraints include availability, geography, and user-selected filters. Sponsored results would need a separately specified policy.

Use successful search sessions as the product objective, with an explicit definition agreed by the team. Purchase or add-to-cart events are possible signals, but purchases are delayed and prices influence them. Keep query relevance, reformulation, returns, and latency visible as diagnostics or guardrails.

Segment exact-item, category, exploratory, misspelled, and rare queries. A system that improves popular category searches while breaking model-number queries may look good on an aggregate metric.

02. Build a lexical baseline first

Start with a field-aware lexical retriever over titles, descriptions, brands, and identifiers. Use structured filters for availability and category rather than hoping the ranking model enforces them. Preserve exact identifier matches and evaluate language normalization carefully.

A BM25-based retrieval baseline can be a useful first system. Product text quality, indexing freshness, synonyms, and filter correctness may matter more initially than a sophisticated ranker.

Then evaluate semantic retrieval for vocabulary mismatch: “shoes for a rainy commute” may describe a need that a listing expresses differently. Semantic similarity should not override a hard filter or invent inventory.

03. Retrieve broadly, rank selectively

Request path
Query + filtersLexical + semantic retrievalMerge + rankEligible results
Run independent retrieval sources in parallel under deadlines. Merge by stable listing ID before expensive scoring.

Retrieve a bounded set from each source, apply constraints consistently, and deduplicate. A rank-fusion method is a reasonable baseline when lexical scores and vector similarities are not comparable.

Reciprocal rank fusion combines rankings using reciprocal position terms. In a common form, each source contributes 1 / (k + rank). An item ranked 1st and 3rd across two sources receives 1/61 + 1/63 ≈ 0.0323 when k = 60. This is an illustrative setting; source coverage and fusion parameters still require evaluation. Elastic documents the method.

After merging, use a lightweight learned ranker over query–listing relevance, exact-match features, availability, and carefully chosen quality signals. Limit expensive cross-encoder scoring to a smaller shortlist only if measured relevance gains justify its latency and cost.

For an illustrative 250 ms budget, reserve 30 ms for request processing, 80 ms for parallel retrieval, 80 ms for ranking, and 60 ms for final checks and margin. Validate this decomposition under load; separate stage p95 values do not simply add up to an end-to-end p95 guarantee.

04. Build labels without copying yesterday's bias

Collect query, displayed listings, positions, clicks, add-to-cart events, purchases, and subsequent returns. Log impressions, not just clicks. A listing never shown is not a known irrelevant result.

Higher positions receive more attention, so raw click-through rate reflects both relevance and exposure. Build a small human-judged query–listing set with clear relevance guidelines to complement behavioral labels. Hold out queries and time periods according to the intended generalization task.

Sample hard negatives thoughtfully: a related but incompatible accessory can be more informative than a completely unrelated item. Apply sampling only within training; evaluate on a candidate universe that resembles deployment.

Use only features available at request time. A listing's future purchases and eventual return rate cannot describe a past request. See the data-leakage guide for the distinction between event time and feature availability.

05. Test relevance at every stage

  • Retrieval: measure coverage of judged relevant items at a fixed candidate budget. Inspect exact-ID and rare-query failures.
  • Ranking: measure NDCG@K using a documented relevance scale and judge agreement. For known-item queries, reciprocal rank of the desired item is another useful diagnostic.
  • Serving: test empty-result rates, stale inventory, latency tails, and pagination consistency.
  • Product: assess user outcomes in a controlled experiment with relevance and reliability guardrails.

Compare against lexical-only retrieval and a simple ordering baseline. Measure cohorts separately and report uncertainty. Search changes can affect sellers as well as searchers, so consider marketplace effects when choosing experiment units and interpreting results.

Connected fundamental

Why NDCG cares about order ↗

A worked ranking example and the assumptions behind the score.

06. Keep results fresh and fallbacks useful

Consume catalog updates through a durable change stream. Apply updates idempotently using listing IDs and versions. Monitor the delay from a catalog change to its searchable representation.

Re-check critical availability constraints before returning results and again in the purchase flow. An index refresh alone cannot guarantee that an item remains available after the search response.

Cache popular query results only with keys that include relevant filters, locale, and ranking version. Use short lifetimes or invalidation for volatile inventory. Avoid sharing personalized results through a cache key that omits the user context.

If semantic retrieval or the learned ranker misses its deadline, return eligible lexical results. Preserve a stable pagination strategy, such as a snapshot plus a deterministic tie-breaker, so a changing index does not needlessly repeat items between pages.

07. Handle the interviewer’s changes

“Semantic search hurts exact model-number queries.”

Check query classification and exact-match handling. Route or boost verified identifier matches with an explicit policy, then evaluate that query segment. Do not force every query through one fusion configuration.

“Clicks improve, but returns increase.”

Inspect whether the ranker favors attractive but misleading listings, low prices, or incompatibilities. Validate the return-attribution window and cohorts before changing the objective. Clicks alone cannot establish satisfaction.

“The new ranker wins training but loses on rare queries.”

Examine query overlap, training concentration, model complexity, and label scarcity. Compare with the baseline on an untouched rare-query set. The overfitting guide explains how to choose an intervention from the evidence.

Common mistakes

Adding raw lexical and vector scores without a justified scale, treating unshown items as negatives, ignoring exact identifiers, or returning unavailable listings because they score highly.

Your answer in one minute

“I would start with reliable lexical retrieval and structured constraints, then add semantic retrieval where it improves query coverage. I would merge candidates, rank a bounded shortlist, and validate with judged relevance plus product experiments. The system would preserve exact matches, keep catalog updates fresh, and fall back to eligible lexical results when expensive stages fail.”

Budget candidate scoring under peak load

Additional original practice exercise · October 3, 2026. Numbers are illustrative assumptions.

For the assumed 1,000 queries/s, take 400 lexical candidates and 400 semantic candidates with 150 listing IDs in common. The union contains 650 candidates, so the lightweight ranker scores 650,000 query–listing pairs/s. If a cross-encoder reranks only the top 40, its workload is 40,000 pairs/s. These are offered scoring rates, not hardware capacity estimates; benchmark representative sequence lengths and batches before sizing workers.

When semantic retrieval times out, the lexical candidate set still needs eligibility checks. Do not wait past the request deadline merely to complete a symmetric pipeline. Record which fallback produced the response so aggregate relevance changes can be separated from a rise in fallback traffic.

Practice: semantic-only relevant items vanish during an outage while exact-ID results remain healthy. Report recall by query class, the fallback fraction and end-to-end latency together; a fast response is not evidence that relevance stayed constant.

Related practice: Choose pointwise, pairwise or listwise ranking losses · Design a fraud detection system

Sources & further reading

Architecture choices, traffic, and latency budgets are illustrative, not a description of a particular marketplace.

Continue your preparation

Choose a connected learning path or browse more ML system design questions. Read our editorial method and attribution policy.