Design Enterprise Semantic Search
Let employees search every company document by meaning, across wikis, drives and tickets, while showing each person only what they are allowed to see.
Like a librarian who understands what you mean, not only the words you type. You ask about 'travel refunds' and get the page called 'expense claims for trips'. The librarian also never hands you a locked file.
Where this analogy stops working: A librarian checks your pass at the desk each time. The search system knows only the permissions it last copied from each source, so it must hear about every change quickly.
- People & sources
- Employee
- Wiki, drives, tickets
- Ingest
- Change queue + chunker
- Meaning
- Embedding model
- Index
- Sharded index
- Search
- Search API
- Reranker
1. Requirements and scope
- Search documents from several sources, such as the wiki, shared drives and tickets, in one box.
- Match by meaning as well as by exact words, then show the best results with a short snippet.
- Show each employee only documents they may open in the original source.
- Reflect a new or edited document within a few minutes.
- Results within about 500 ms for 95 of every 100 searches (the p95).
- A permission change must take effect quickly; a leak is worse than a slow result.
- Search quality is measured, not guessed.
- Index updates must not slow down searches.
2. Back-of-the-envelope numbers
- Writes: 6 documents indexed a second (46%)
- Reads: 7 searches a second (54%)
Balanced: reads and writes are close. Both paths need care, so neither can be slow.
3. API
4. Data model and storage
CHUNK(id, doc_id, source, text, embedding, allowed_groups[], updated_at) · DOCUMENT(id, source, title, url, owner, version) · GROUP_MEMBER(group_id, employee_id)
5. The design, in three versions
Version 1: Keyword search over one source
A nightly job copies the wiki into a keyword index. The search box matches the exact words people type.
Search v1: Nightly Keyword Index Version 1 of 3
The picture follows one request through the parts of this version, in order. Under it, switch a part off to see what the request does without it.
One request, step by step
Each numbered arrow is one step. Press "Simulate Request Flow" to follow them one at a time.
- The order of the steps
- A request or its reply
The parts: switch one off
1. People & sources
2. Ingest
3. Index
4. Search
Example figures
- Time budget
- < 500 ms
The steps in words0 of 3 steps shown
Employee to Search API
GET /v1/search?q=travel refunds
Search API to Index
Match the words "travel refunds"
Search API to Employee
Pages containing those words
Write path, read path and failures
Each path follows one request through the final design (version 3), one hop at a time.
Write pathIndex an edited document
- Drive
- Change queue
- Chunker
- Embedding model
- Index
Drive to Change queue
An edit or a sharing change in a source sends a change event.
Change queue to Chunker
A worker reads the document again and cuts it into passages.
Chunker to Embedding model
Each passage gets a vector.
Embedding model to Index
The index replaces the document's old passages, along with the people and groups who may see it.
Read pathSearch
- Employee
- Search API
- Index
- Reranker
Employee to Search API
An employee types a question.
Search API to Index
One query runs a keyword search and a vector search together, limited to documents this employee may open.
Index to Reranker
The reranker reads the top 50 results with the question and orders the best 10.
Reranker to Employee
The results appear with links. The permission filter ran inside the query, not after it.
What breaks, and what happens then
Someone loses access, but the index has not caught up
- What users see
- For a few minutes, a search could show a document they can no longer open.
- What the design does
- Sharing changes go to the front of the queue, and the Search API checks access to each result before showing it.
The embedding model is upgraded
- What users see
- Old and new vectors cannot be compared.
- What the design does
- Build a second index with the new model, test it on the judged queries, then switch.
A large source is copied in again from scratch
- What users see
- New edits wait behind it in the queue.
- What the design does
- Live edits use their own queue, ahead of bulk work.
The reranker is slow
- What users see
- Searches take longer than the 500 ms goal.
- What the design does
- Give the reranker a time limit. If it runs out, show the results in their first order.
6. Deep dives
7. Follow-up questions
- An employee leaves a project. When do its documents stop showing up? (As soon as the group change event arrives, because the search filters by the employee's current groups at query time.)
- Users say results got worse last week. How do you find out why? (Rerun the judged queries against last week's settings, compare scores per change, and check the click data for the drop.)
What it costs
The index is modest: about 245 GB of vectors. The steady cost is embedding every changed document, about 6 a second. Embed only the parts of a document that changed, and store smaller vectors.
Another way to design it
You can build a separate index for each team or source. Permission checks become simple, because a person searches only the indexes they may see. A search across the whole company then needs many queries.
8. How answers are judged
A passing answer at Mid level. A complete design with numbers: about 7 searches a second, 80 million chunks, about 6 edited documents a second. It explains embeddings and hybrid search, and goes deep on permissions.
| What is judged | Junior | Mid | Senior | Staff |
|---|---|---|---|---|
| BreadthHow much of the system does the answer cover? | Names the core parts: clients, servers, a database and a cache. | Covers the whole main flow, from the request to the stored data and back. | Builds a complete design without being led through it. | Covers the system, the systems around it and who owns each part. |
| DepthHow far does it go into the hard parts? | Explains what each part does and why it is there. | Goes deep on one part, such as the database or the cache. | Goes deep on the two or three riskiest parts. | Goes deepest where the risk is largest, and explains why the risk is there. |
| DrivingWho leads the conversation? | Follows the interviewer, step by step. | Moves forward alone, with an occasional nudge. | Leads the conversation from start to finish. | Changes the problem when the question asked is not the right one. |
| Trade-offsAre choices compared and justified? | Names more than one option. | Says why one option was picked over another. | Compares options in detail, with what each one costs. | Ties each choice to cost, speed and risk for the business. |
| Unclear questionsWhat happens when the question is vague? | Answers the questions that are asked. | Asks questions to make the problem clear. | Sets the scope and says what is left out. | Questions the assumptions behind the problem itself. |
| ScopeWhat does it consider beyond the normal path? | Covers the normal path, when everything works. | Adds what happens when a part fails. | Adds growth: what breaks at ten times the load, and the fix. | Adds abuse, cost and the daily work of running the system. |
Requirements and scope
Before I design, I want to check the scope. Which sources come first, and how fresh must results be? Each employee must see only what they can open in the original source. I will assume edits show within minutes, and that a leak is worse than a missing result.
Everyone in the company works together, so I will let every employee search every document. I can fix permissions later if someone complains.
Shows: Unclear questionsThe difference: Search makes hidden files easy to find, so it would expose salaries, legal and HR files to everyone. Permissions must be part of the first design.
Estimates
10,000 employees searching 20 times a day is 200,000 searches, about 7 a second over working hours. 80 million chunks of 768 numbers at 4 bytes each is about 245 gigabytes of vectors, or about 61 gigabytes stored as 1-byte numbers.
20 million documents at one vector each, 3 kilobytes per vector, is about 60 gigabytes in total.
Shows: DepthThe difference: Each document is split into several chunks, about 80 million in all, and each chunk needs its own vector. That is about four times more.
Core design
Connectors pull each source, split documents into chunks of a few hundred words, and embed each chunk. A search runs keyword and vector search together, filtered to this employee's groups inside the query. The two lists are merged, then a reranker orders the best few.
I would search all chunks by meaning, take the top 10, and then remove any the employee is not allowed to see.
Shows: DepthThe difference: Filtering afterwards can leave few or no results, and a single bug would show a locked document. The filter belongs inside the query.
Deep dive
The hard part is knowing whether a change helps. I would keep a set of real queries with judged good results and score every change to chunking, models or ranking against it. Click data shows problems the judged set misses.
I would try a new embedding model by switching the index to it for everyone, and see whether people complain.
Shows: DepthThe difference: Complaints come late and say little. Vectors from two models also cannot be mixed, so test on judged queries with a second index first.
Failures and trade-offs
If the embedding service is down, searches fall back to keyword results, which still work. If change events stop, a nightly full sync catches up, and an alert fires when the index falls behind. A permission removal is applied before any other update.
If the embedding service is down, the search page shows an error until it comes back.
Shows: Trade-offsThe difference: Keyword search does not need the embedding model, so it can keep answering. A degraded result beats no result for most searches.
We wrote this guide in our own words, informed by public interview guides such as AlgoMaster and Hello Interview. We are not connected to either site. Interviewers differ. The guide and the example answers show the direction each level takes, not a checklist.
10. Check your design with your own AI
Write your design first. Then copy this prompt into the AI chat you already use, and add your design at the end. It asks for a score in each area, one fix for each, and two follow-up questions.
The site sends nothing anywhere. An AI review can be wrong, so check what it says against sections 8 and 9.
See the prompt
You are a system design interviewer. Review my design for the interview problem below. Problem: Design Enterprise Semantic Search Let employees search every company document by meaning, across wikis, drives and tickets, while showing each person only what they are allowed to see. What users must be able to do: - Search documents from several sources, such as the wiki, shared drives and tickets, in one box. - Match by meaning as well as by exact words, then show the best results with a short snippet. - Show each employee only documents they may open in the original source. - Reflect a new or edited document within a few minutes. How well it must work: - Results within about 500 ms for 95 of every 100 searches (the p95). - A permission change must take effect quickly; a leak is worse than a slow result. - Search quality is measured, not guessed. - Index updates must not slow down searches. Numbers to assume: - 10,000 employees, each searching about 20 times a working day. - 20 million documents, split into about 80 million chunks; about 500,000 edits a day. - The busiest hour is about twice the average. Judge my design at the Mid level. A passing answer at this level: A complete design with numbers: about 7 searches a second, 80 million chunks, about 6 edited documents a second. It explains embeddings and hybrid search, and goes deep on permissions. For each area below, say whether my design is strong, fine or weak. Give one reason and one fix for each: 1. Requirements and scope 2. Estimates 3. Core design 4. Deep dive 5. Failures and trade-offs Then ask me the two follow-up questions an interviewer would ask next. Do not write a full model answer for me. My design: [Describe your parts, how one request moves through them, and why you chose each one.]