How it works
A baseline ranks normalized completed searches by count, then breaks ties deterministically (for example, alphabetically) so a list does not flicker between equal scores. Lifetime popularity can be stale, so a time-decayed score can favor recent activity by shrinking older counts. With an example half-life of seven days, a count loses half its weight each week. A term with 10,000 searches two weeks ago and none since scores 2,500. A term with 3,000 searches today scores 3,000 and now ranks higher, even though its lifetime count is far lower.
A product catalog may also account for availability or quality, so a sold-out item does not lead the list. Decide whether rankings differ by region and locale before mixing their signals. Popularity also feeds itself, because people tend to choose what they are shown, so early leaders can stay ahead. Elasticsearch’s completion suggester takes a per-entry weight, so a scheduled job can write decayed scores into it.
Keep more internal candidates than displayed slots. If the visible list has five entries and policy blocks one, a cache with exactly five gives only four. Filter a larger ranked candidate set, such as 20, then take five. That quadruples list storage compared with keeping five, so size it from how often filters actually remove entries. Public popularity and personal search history are different products; personal suggestions need account-aware access and private caching.
A blocked phrase is first in a cached top-five list. How can the service still show five safe results?
Keep additional ranked candidates, apply policy filtering, and select five remaining entries. Correct the source data so the phrase stays excluded.
Use this as a guide for self review; written answers are not graded.Keep in mind
- Define ranking signals, time window, context, and tie-breakers.
- Filter before selecting the final K results.