Design fast query-to-listing retrieval over tens of millions of listings
eBayApplied Scientist · Technical ScreenLast updated
An ML system design question on retrieving relevant listings for free-text search queries across a catalog of tens of millions of items with low latency. It tests candidate generation, indexing, embedding training, freshness, filtering and scaling, plus the offline and A/B test metrics used to evaluate retrieval.
Users type free-text search queries into a marketplace, and the catalog holds tens of millions of listings. Design how the system quickly retrieves the listings relevant to a query. Expect the discussion to drill into each component you propose.
Constraints and Clarifications
- The catalog holds tens of millions of listings. No latency budget, query volume, or freshness requirement was specified; ask for them.
- Assume listings have at least a title, description, category, structured attributes, price and availability.
Clarifying Questions
- What latency budget does retrieval get within the full search request, and what peak query rate must it sustain?
- How quickly must a new, edited, sold or removed listing be reflected in results?
- Does retrieval produce a candidate set for a downstream ranker, or the final ordered results?
- Which hard filters must be honored (category, price range, location, condition, availability)?
- What interaction logs exist (queries, impressions, clicks, purchases) for training and evaluation?
Hints
Hint 1
Precompute: Think about what can be computed for every listing before any query arrives.
Hint 2
Complementary signals: Exact term matching and semantic matching each fail on different kinds of queries.
Follow-up questions
- How do you train the query and listing encoders, and where do the negative examples come from?
- A listing sells out. How quickly, and through what path, does it disappear from both the lexical and the vector index?
- How do you apply a price or category filter with approximate nearest-neighbor search without losing recall?
- Which offline metrics and which A/B test metrics would decide whether a new retrieval model ships?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.