Product search
0-day streakReview

Your progress

Level 1

0 XP100 XP to level 2
0day streak
0best streak
0topics started
0cards reviewed
    Review cards

    Progress is stored only in this browser. No account is required.

    Design product search for an online store: the 60-second story

    Design product search

    “red running shoes under 2000” is five words, and a form you can’t see.

    Category: sports shoes. Colour: red. Price: below ₹2,000. Best bets first, from 100 million listings.

    200k/s

    searches when a big sale opens at midnight

    Ten times a normal day, within minutes. The 250 GB index would fit one large server; CPU per query at peak forces 250 nodes.

    What is one document?

    Bad: Per product, with arrays

    Arrays forget pairs: “red, size 9” finds a shoe nobody can buy.

    Good: Per visual variant

    One per colour, sizes in stock inside; collapse to one card per shoe.

    Only “running shoes” is left to match as text

    Fix “runing” from query logs. Extract red and under 2000. Predict the category. Precise constraints become filters; noisy ones like colour become boosts.

    50 million documents in, 40 cards out

    Each stage is pricier per document and sees fewer. Learning to rank re-scores only the top 1,000; business rules touch only the final page.

    Sale peak: 50,000 price changes a second. Each index write rewrites a whole document, on 25 copies.

    The trick

    Cards read exact prices from a live store. The index gets only changes that flip a filter.

    Delivery by tomorrow to 560001? Index warehouses, not pincodes

    Pincodes per SKU: 250 billion postings. Instead, each pod holds a 600 KB map from pincode to warehouses, and the index filters on stock_wh.

    Past the plan? Step down, don’t fall over

    1. Rescore the top 300, not 1,000
    2. Serve facets from cache only
    3. Cap pages at 20
    4. Shed scrapers and bots first, then deep pages

    Remember

    One document per visual variant. Parse the query into filters, rank in stages, read exact price and stock from a live store, and pre-scale for sale day.