Build and verify a new index before switching readers, retain rollback and check cross-index compatibility.
Index alias cutovers: switch retrieval generations without mixed results
Treat each index build as a generation
An index generation is an immutable serving candidate with a corpus snapshot, parser settings, analyzer configuration and model version. Updating a live index in place can mix old and new representations. Instead, build generation B while readers use A, replay changes until B reaches an acceptable ingestion watermark, and verify it before cutover. An alias or routing pointer lets the application switch the serving generation as one operation. The pointer is small; rebuilding the index is the costly work.
Check compatibility across every retrieval branch
A retrieval service may read a lexical index, vector index, metadata store and citation store for one answer. Changing only one alias can produce a passage ID that the other stores cannot resolve, or a query vector encoded with the wrong model. Record a manifest of compatible generations and switch that manifest atomically at the application boundary. Multi-index snapshots explain why a single consistent view matters; embedding migration covers vector-specific compatibility.
Gate the switch on observed evidence
Compare the candidate generation on labeled slices for exact identifiers, paraphrases, deleted documents, access restrictions and fresh updates. Inspect top-K recall, unsupported claims, p95 latency and index size. A green aggregate can hide a severe loss for rare serial-number queries. Run shadow traffic with identical authorization filters and no user-visible answers, then compare traces under a fixed sample budget. Keep a minimum freshness condition so the new index does not silently omit the last ingestion window.
Switch once and keep rollback bounded
Before cutover, pin in-flight requests to one generation. Change the alias or manifest pointer atomically, then start new requests on B. Retain A until rollback tests, cache invalidation and a short monitoring period complete. Reversing the pointer is a rollback only if A can still serve current permissions and deletion rules. A deleted document must not reappear after a rollback; apply tombstones to both generations or use a central authoritative filter. Delete races become more important during dual writes.
Audit the generation used by each answer
Log the serving manifest ID, corpus watermark and relevant model versions with each retrieval trace and citation. If an incident spans a cutover, those fields distinguish an index defect from a changed query distribution. Test partial failures: a stale replica, failed alias update and cache entry from A should never make one answer combine A and B without an explicit compatibility rule. An index alias is a routing device, not evidence that data or permissions are correct.
Worked contract
from dataclasses import dataclass
@dataclass(frozen=True)
class IndexGeneration:
name: str
corpus_revision: int
model_revision: str
checked: bool
def choose_generation(current: IndexGeneration,
candidate: IndexGeneration,
required_corpus_revision: int,
query_model_revision: str) -> IndexGeneration:
if not candidate.checked:
raise ValueError("candidate has not passed release checks")
if candidate.corpus_revision < required_corpus_revision:
raise ValueError("candidate is behind the freshness gate")
if candidate.model_revision != query_model_revision:
raise ValueError("query and passage models differ")
return candidate
active = IndexGeneration("lexical-a", 81, "encoder-r4", True)
next_index = IndexGeneration("lexical-b", 87, "encoder-r4", True)
selected = choose_generation(active, next_index, 85, "encoder-r4")
assert selected.name == "lexical-b"
assert active.name == "lexical-a"Performance and operating cost
The gate shown uses O(1) time and space; index construction remains proportional to corpus size and token or vector count. Dual generations temporarily raise storage, ingestion and validation cost. Actual pointer updates need a backend operation that is atomic for readers, plus a consistent application manifest when several indexes are involved. The code models a gate, not a distributed alias update or a substitute for live permission checks.
Common Mistakes
- Switching a lexical index and vector index independently without a compatibility manifest.
- Treating a successful alias update as proof the candidate contains recent deletions.
- Deleting the prior generation before rollback and in-flight requests are finished.
- Using a rollback that restores documents whose access has since been revoked.
Validation drill
Build two generations from 113 documents and replay three changes, including a deletion. Verify a freshness gate, a failed candidate, an atomic pointer switch, in-flight request pinning and a rollback that does not reveal the deleted record.
Read next
- Snapshot-consistent retrieval across changing indexes
- Embedding migrations: keep query and document vectors in one space
- Index watermarks: measure what the retriever has actually seen
- Incremental retrieval ingestion: replay events without reviving deleted passages
