← All problems
Dashboard
Courses
Problems
Badges
Theme
Sign inStart free
Problem 051 · Databases and storage

Design Semantic Document Search

Medium 55 min

A company with 60,000 employees keeps 20 million documents across its wiki, shared drives and ticketing system. Keyword search fails when people describe what they need in different words, so the company wants search by meaning: 'how do I expense a client dinner' should find the travel policy even if it never uses the word 'dinner'. Documents are split into passages and turned into embeddings by a model; about 200,000 documents change every day. At peak there are 500 searches per second. Results must arrive in under a second, and nobody may ever see a passage from a document they are not allowed to open.

Functional requirements

  • Index documents from several sources by splitting them into passages and embedding each one
  • Answer natural-language queries with the most relevant passages and their documents
  • Combine semantic results with exact keyword matches (names, error codes, ticket IDs)
  • Show only results the searching user has permission to read
  • Reflect edits, deletions and permission changes in search results

Non-functional requirements

  • Search returns in under 800 ms at p95
  • Permission changes and deletions take effect in results within 5 minutes
  • Re-embedding the whole corpus for a new model is possible without downtime

Constraints and scale

  • 20 million documents, about 300 million passages with 768-dimension embeddings
  • 200,000 changed documents per day
  • 500 searches per second at peak

You will practise

  • Build an asynchronous embedding pipeline and an approximate nearest-neighbour index
  • Merge vector and keyword results with hybrid ranking
  • Enforce document-level access control inside retrieval, not after it
Show 3 hints
  1. A user searches for 'INC-48213'. Will an embedding find that ticket reliably?
  2. If you retrieve the top 10 passages and then drop those the user cannot see, what might they end up with?
  3. How long does it take to embed 300 million passages, and where does that work happen?

Ready to build?

Open the canvas, place your components and explain your decisions. Your draft saves automatically.

Sign in to start

Failure scenarios

  • A confidential passage appears in resultsHR restricts a document about planned redundancies. Ten minutes later an employee outside HR searches 'restructuring plans' and sees a passage from it.

Run them from the workspace once your design is in place.