Data and Knowledge SystemsIngestion and freshnessPrincipal
How should an index distinguish an omitted field, an explicit clear and a replacement value?
By Amit Kumar3 min readWorked answer includedReviewed 28 Sept 2026
The question
Interview question
A source sends a partial customer update containing only id and display_name because the address did not change. After ingestion, the stored address disappears. Trace the event through deserialization and the outbound index operation. Define leave, set and clear semantics, and explain how your update protocol handles out-of-order changes to different fields.
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
A partial update describes changes to selected fields. A full snapshot describes the entire replacement state. The missing address has opposite implications under these contracts, so the consumer must know which one it received before constructing an index write.
There are at least three meanings to separate: field absent means leave it alone, explicit null means clear it, and a concrete value means replace it. The consumer may deserialize the sparse event into a full customer object, read a default null for the missing address, then send a whole-document replacement to search. Or it may construct a patch with address: null, which under JSON Merge Patch means removal. The source did not ask for either operation. The mistake is at the conversion between the source event's presence semantics and the index write's semantics.
I would inspect the raw event, its schema, the deserialized representation and the exact outbound index request for one affected customer. Do not infer intent from a language getter that returns a default value when a field is missing. Protocol Buffers' field-presence guidance explains why an implicit-presence scalar cannot always distinguish an unset field from one explicitly set to its default. For partial updates, use explicit presence, a field mask, or an operation format that can express leave, set and clear without ambiguity. If the source publishes full snapshots instead, say so in the contract and replace the whole document only from a complete authoritative snapshot.
A concrete example makes the three states visible. Under the source contract, a patch containing only a display name preserves the stored address. A patch explicitly clearing the address removes it. A patch supplying a new address replaces it. JSON Merge Patch uses null for removal, so a product that needs to store a literal null must choose a representation that can express that distinction. Presence must survive every serializer and mapper, not merely the message schema.
Ordering is more subtle for patches. Suppose source revision 12 changes the name and revision 13 changes the address. If 13 arrives first and the sink rejects every lower global revision, it may discard 12 and permanently lose the name change. Replaying patches in source order, fetching a complete latest snapshot, or using source-defined field versions can solve different versions of this problem. A document-level version comparison alone is sufficient only if the accepted payload fully supersedes the older state or the protocol otherwise preserves all required changes. Make the chosen application operation idempotent so replays do not apply a relative increment twice. Test omitted, explicit null and concrete address values through serialization, index write and query visibility. A search result showing the old address for a short refresh interval is a different problem from the address being durably erased.
The interview decision is whether the event stream carries patches or state snapshots. Treating one as the other can silently destroy correct data at scale, even when every consumer reports successful processing.
Validate the actual outbound payload, not just the in-memory object. A typed object may already have erased field presence by filling defaults, making a correct index API incapable of recovering the source intent. Add fixtures for omitted fields, clear operations, default values, repeated delivery and two independent field changes completing in reverse order. A test passes only when the final searchable state has the intended name and address, not when both messages received successful acknowledgments.
Related questions
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