</> MAANG.io
system design · 301

Advanced

Master system design interviews with scalable architecture patterns, distributed systems, and real-world design challenges.

0/480 solved 0% complete

Section 8: Closer Is Not Better - Deep Dive: Ranking & Relevance

Executive Summary: Section 7 handed us candidates; this section orders them. We separate hard filters from soft signals, normalize text, distance, quality and popularity onto one scale, and weight them differently when the query is empty. A Bayesian rating stops a 5.0★ shop with 3 reviews beating a 4.6★ shop with 900. Ranking runs in two stages, an in-index L1 over at most 5,000 candidates and an L2 re-rank of the top 200, with a placeId tie-break for stable pages. We close with how to measure whether it works.

Sam's search now holds 24 places: ramen, open now, inside 1 km. Sam will see 20, and the first three matter most.

Interviewer: "Noodle Lab is 400 m away and rated 5.0. Menya Kaze is 650 m away and rated 4.6. Why isn't Noodle Lab first?"

You: "Because Noodle Lab's 5.0 comes from 3 reviews and Menya Kaze's 4.6 from 900. A ranker that can't tell weak evidence from strong fills every list with places reviewed once by the owner's cousin."

Filters Decide Membership, Ranking Decides Order

Filters are hard: category, price level, minimum rating (on the displayed average; ranking uses the Bayesian score) and "open now" when requested. A place passes or it doesn't. Ranking is soft: text, distance, quality and popularity trade off against each other. When Sam hasn't asked for "open now", it becomes a small boost, so a great place opening in twenty minutes can still appear lower down.

Mixing them is a classic bug: if "open now" were merely a heavy weight, a famous closed restaurant could outscore every open one and send Sam to a locked door. Filters run first, on postings inside the index (Section 7's 70 → 52 step), so scoring only touches places allowed to appear.

Quick check before moving on:

Sign in to continue reading

The rest of this lesson is available with a free account. Signing in with Google or Microsoft is free.

Sign in to read the full lesson

Sign in to MAANG.io

Use your Google or Microsoft account — no password to remember.

Continue with Google Continue with Microsoft

Please accept the terms above to continue.