Data and Knowledge SystemsIngestion and freshnessPrincipal
How would you provide read-your-writes answers before a document finishes indexing?
By Amit Kumar3 min readWorked answer includedReviewed 26 Sept 2026
The question
Interview question
An editor updates a support policy and receives a successful source-write response. Embedding and search indexing take several minutes, but the product promises that the editor can ask about the edit immediately. Define the consistency guarantee and design the answer path. The rule and its exception are then changed as a two-document release. Explain which readiness evidence is required before answering.
Draft your approach first
Take a few minutes before you read the answer. Name the constraint that matters most, the failure you are designing for and how you would know it worked.
Reveal the worked answerWorked answer
The source write being committed, the search index seeing it, and the assistant answering with it are three separate events. A successful edit response is not evidence that every search representation is ready. “Immediately” needs a scope. Does this editor need to read their own changed document, do all authorized users need the new policy, or must a query over the whole corpus reflect a coherent release? Those are different guarantees.
Read-your-writes means that a client reading after its own successful write does not observe an earlier version of that item. It does not require every other reader to see the new version at that instant. For that experience, the source returns an immutable revision token. The query carries at least that revision requirement for the edited object. If lexical, vector, extracted text and citation mapping for that revision are ready within a bounded wait, answer from it. If not, fetch the authoritative source revision and build a scoped, permitted evidence path for that user's question. If this path cannot parse the edit within the promised deadline, the UI must say it is still processing. If product insists that a success response means an immediately answerable edit, the write flow must wait for a supported synchronous evidence path before returning that status. Do not mix a new source snippet with an old exception table and call the result current. A stale indexed revision should be ineligible once the query knows a newer revision is required, even if its embedding is the nearest neighbor.
A scoped overlay is a temporary evidence path over the edited source revision while the main index catches up. For a hypothetical revision 42, the request carries “at least revision 42” for this document. The query coordinator can wait briefly for readiness, or fetch and parse revision 42 into an authorized per-request evidence set. It must suppress revision 41 for that same identity. If the question requires facts outside the overlay, it still needs a coherent way to combine them, rather than labeling the entire corpus current. Cache the overlay only under the correct user, source revision and permission scope.
An Elasticsearch index write can use refresh=wait_for to wait until that write is search-visible. That applies to the specified index operation. It does not wait for an upstream connector, parser, vector generation, second index, or source authorization update. Forcing refresh on every edit can also create costly small segments. I would use a generation or readiness record across the actual stages and only promise the scope that record proves. The overlay path must check current permissions and cite the source revision it read, not a future index URL guessed from the old one.
Now the rule and its exception change together. Per-document read-your-writes is insufficient. The source needs a release or manifest that declares the coherent pair. The query pins that release and waits for both documents, or reports that the new release is not ready. How do you stop an answer from mixing two document versions? covers that cross-document invariant. For the immediate-edit promise, measure time from source commit to eligible answer, old-revision disclosures after a user's token, overlay usage, and failures that honestly report pending work.
A useful failure test delays only the exception document while the main rule becomes ready. An answer applying the new rule with the old exception violates the release contract even though it satisfies the edited document’s minimum revision. Carry a release identity that names both revisions and make the evidence assembler check it. The trade-off is added waiting or explicit pending responses during partial readiness. A stale answer presented as immediate success would hide that cost rather than remove it.
Related questions
- How should ingestion scheduling protect tenant freshness under repeated edits and bulk imports?Principal
- How should an ingestion worker identify and activate the correct document revision after replay?Staff
- How do you build a search index from a snapshot and change stream without losing updates or reviving deletions?Principal
Keep practising data and knowledge systems
Follow another question in this area, or search the complete library.
Get my essays on AI engineering and distributed systems by email. Subscribe to ArchCrux