All Questions
Vector Search hard

An e-commerce search service holds 50M product vectors in an HNSW index. A common query applies the filter `in_stock AND region=EU AND category=X`, which matches about 0.2% of the corpus. The service asks the ANN index for the top 100 and then applies the filter, and it often returns 0 to 3 products. Which design fixes this most reliably?

  1. A Oversample by raising k to 1,000 before filtering; a 10x oversample leaves plenty of matches for a 0.2% filter.
  2. B Rebuild the HNSW graph with a higher M so each node has more edges, raising recall and surfacing more matches.
  3. C Pre-filter or use filter-aware traversal, with an exact flat scan when the match set is small.
  4. D Retry the ANN query with exponentially larger k until at least 10 filtered matches come back, then return those.

One system design question a day, with spaced repetition so the ones you miss come back.

Get the app

Related questions