The interview problem

Practice prompt

Design retrieval for an enterprise assistant over ten million frequently edited documents. Most edits should become searchable within two minutes. Deleted documents and revoked permissions must stop contributing to new answers under a stricter access contract. Handle delayed embedding jobs, failed updates and a full index rebuild while serving queries.

Original ML design practice, not a reported interview. Workload assumptions are illustrative. Technical references retrieved September 27, 2026.

1. Define freshness at the user-visible boundary

Measure from authoritative source commit to the version being usable in retrieval, not merely queued or acknowledged by the index API. Clarify whether the target is p95 or p99 and whether large documents have a separate objective. Two minutes is the assumed ordinary-edit target, not a universal product requirement.

Separate relevance freshness from authorization. A stale paragraph may give an outdated answer; a revoked document may disclose information the user can no longer access. Assume every new context assembly must pass an authoritative or explicitly bounded-staleness access check. Define the authorization decision point and handling of already-running generations; an asynchronous index cannot promise instantaneous revocation everywhere.

Clarify source capabilities: change feeds, monotonic revisions, deletion signals and permission APIs. If a source offers only hourly polling, an end-to-end two-minute freshness promise is impossible without changing the source integration or narrowing the promise.

2. Separate document control from expensive enrichment

The ingestion path is source change feed → durable event log → document version registry → fetch/parse/chunk workers → embedding workers → versioned index writes. The registry stores tenant, document ID, source revision, content digest, deletion state, access-policy revision and published chunk generation. Keep durable source cursors and periodically reconcile missed changes.

Content edits trigger parsing and embedding. Permission changes update access state without waiting for embeddings. Once observed, deletions mark the document unavailable in the serving registry before enrichment work and schedule physical removal from lexical indexes, vector indexes and caches. Authorization and tombstone lookup should remain available even when expensive enrichment is backlogged.

Use stable document identity plus revision and chunk ordinal for chunk IDs. Record the embedding model and chunker versions. A query must use an embedding compatible with the searched vector index; a model upgrade is not just another content edit.

3. Prevent old work from resurrecting old content

Suppose revision 11 starts embedding, revision 12 finishes first, and then the slow revision 11 job returns. Workers write into revision-specific staging entries. Publication conditionally advances the document's active generation only if the source revision is still eligible and newer than the published version. Perform the eligibility/version comparison and active-generation update atomically in the registry, including the deletion state; a separate check and write would permit a deletion race. Reject obsolete completion, even if its embedding call succeeded.

Publishing a document with many chunks is a multi-record operation. Stage all expected chunks, verify their search visibility, then switch the serving registry's active generation. Queries validate candidate generations and fetch matching text; never combine revision 12's vector with revision 11's paragraph. Keep the previous generation only if the configured freshness and access policy permits it.

Some search engines acknowledge writes before they are visible to searches; Elastic documents this distinction through refresh behavior. Do not confuse a successful index request with completed publication. A generation switch without visible chunks creates an avoidable recall gap. If a backend cannot supply the required visibility boundary, state the weaker contract and use verification probes or a supported snapshot/alias strategy.

Retain tombstones long enough to reject delayed events, replayed jobs and rebuild snapshots. Use a monotonically increasing source revision or a documented ordering mechanism. Wall-clock timestamps from unrelated producers are not automatically a safe total order.

4. Validate retrieved candidates before using their text

The query path authenticates the tenant/user, retrieves lexical and vector candidates, checks active versions and permissions, reranks eligible candidates, fetches the matching text and assembles context. Use index-side permission filtering where supported to reduce wasted work, plus a current authorization check at the required boundary. Do not send unauthorized text to a reranker or language model and filter it only afterward.

Post-filtering can reduce recall when stale chunks occupy the top results. Overfetch within a bounded latency budget and refill when possible; track discarded candidates. If too little eligible evidence remains, answer with an explicit limitation or abstain rather than treating obsolete text as a convenient fallback.

Cache entries need tenant and authorization scope, document generation and relevant policy version. A cached generated answer can contain revoked information even after its source chunks disappear. Track answer dependencies or require access revalidation before serving cached text. A cache TTL alone does not satisfy a stricter revocation contract.

For a permission change during generation, define whether access is evaluated at context assembly or rechecked before delivery. If the product requires the latter, buffer the answer until the check passes; previously streamed tokens cannot be recalled. Source outages should cause protected-content checks to fail closed or follow an explicitly authorized bounded-staleness policy.

5. Calculate the embedding and recovery budget

Assume ten million documents with five chunks each: 50 million vectors. At 768 dimensions and four bytes per float, vector payload alone is 153.6 GB. Three copies require 460.8 GB before graph/index structures, text and metadata. Quantization can reduce payload but needs recall and ranking validation.

If 1% of documents change once each day and every edit re-embeds five chunks, the workload is 100,000 × 5 = 500,000 chunks/day, approximately 5.79 chunks/second average. A 20-times burst reaches about 116 chunks/second. Coalescing repeated updates to the same document reduces wasted embedding work when intermediate versions do not need to be served.

A one-hour outage at a sustained 100 chunks/second accumulates 360,000 chunks. With 300 chunks/second processing capacity and continuing arrival at 100, the net drain is 200 chunks/second, so catch-up takes 1,800 seconds, or 30 minutes. Oldest-update age remains high during recovery even when instantaneous throughput looks healthy.

For a two-minute edit objective, budget source capture, queueing, parsing, embedding, indexing and visibility separately. Adding stage p95 values does not prove end-to-end p95; measure complete traces. Separate access/deletion work from bulk rebuilds so an expensive migration cannot consume the capacity needed to enforce current access.

6. Rebuild without losing concurrent changes

Build a new index generation from a source snapshot with an associated change-log boundary. Replay later changes, including tombstones and permission updates, until the new generation catches up. Validate document coverage, retrieval quality, access filtering and lag before switching query routing. Keep a rollback generation only while it can enforce current eligibility.

Dual writing alone is insufficient if writes can fail on one side. Retain replayable events and per-generation progress, retry idempotently and reconcile counts plus sampled contents. A source snapshot without a consistent log boundary needs a source-specific reconciliation strategy; do not claim a lossless cutover merely because both indexes have similar sizes.

A rollback must not restore revoked access or deleted documents. Keep the current serving registry authoritative across index generations. If an old index uses incompatible embedding representations or policy semantics, it may no longer be a valid rollback target.

7. Test freshness and access failures separately

Inject reordered revisions, duplicate events, deletion during embedding, missed permission changes, partial chunk writes and stale answer caches. Verify that old jobs cannot republish deleted content and that protected text never crosses the authorization boundary. Run a rebuild while edits continue and compare known source revisions with returned citations.

Measure source-to-search lag, oldest unprocessed edit, stale-candidate discard rate, permission-check failures, removal propagation time and answer freshness. Include quality tests where a newly corrected policy contradicts its earlier version. Merely retrieving the latest timestamp does not guarantee the answer uses the correct evidence.

Foundation: explain indexing acknowledgement versus visibility. Senior: publish a multi-chunk revision without mixing versions. Staff: define a revocation contract for streamed answers and index rollback.

Score 0–2 each for source contracts, version publication, access enforcement, realistic capacity and failure validation. Full credit requires an explicit behavior when fresh authorized evidence is unavailable. Continue with RAG assistant design and change-data capture.

Sources and next steps

The multi-stage architecture, source-revision registry and access contract are original design choices. Backend concurrency controls do not automatically impose ordering on external source revisions or provide cross-system transactions.

Continue your preparation

Choose a connected learning path or browse more ML system design questions. Read our editorial method and attribution policy.