Embedding model migration: how to re-index a RAG system without downtime
How to plan an embedding model migration: why vectors from different models cannot be mixed, a blue-green re-indexing pattern, cost drivers and a cutover checklist.
A RAG index goes stale the day after launch. How to detect changed and deleted documents, sync incrementally with content hashes, and stop retired policies from being quoted as current.
A RAG system is usually demoed on a snapshot of documents that is correct the day it is indexed. Then the refund policy changes, a price list is replaced, an employee handbook section is withdrawn, and the assistant keeps answering from the old text with full confidence. RAG knowledge base freshness is the problem of making sure the index tracks the source of truth, including the documents that disappear.
This post covers how to detect change, sync incrementally instead of re-embedding everything, handle deletions, and make staleness visible when it does slip through.
The index is a copy. It is built from documents at one moment and then diverges, in three ways:
The deletion case is the dangerous one. A stale edit returns an outdated answer; a stale deletion can return content you were legally or contractually required to remove. If personal data is involved, erasure has to reach the vector store too, as discussed in our DPDP Act and AI compliance guide.
Pick the cheapest signal your source reliably offers:
| Signal | How it works | Weakness |
|---|---|---|
| Source webhook or change feed | Source pushes an event on create, update, delete | Events can be dropped; needs a safety-net scan |
updated_at / ETag / version | Poll and compare to the stored value | Some systems bump it without real content change, or not at all |
| Content hash | Hash the extracted text and compare | Requires fetching and parsing every document on each scan |
| Full re-index on a schedule | Rebuild everything nightly or weekly | Wasteful, and leaves a gap between runs |
A robust setup combines two: events or timestamps for speed, plus a periodic hash-based reconciliation scan that catches whatever the events missed. Treat the scan as the source of correctness and the events as an optimisation.
The core is a manifest: one row per source document holding its stable ID, content hash, last-indexed time, and the IDs of the chunks it produced. Each sync run then does the following:
Because only changed documents are embedded, the cost of a sync scales with the amount of change, not the size of the corpus. Chunk boundaries matter here: if your chunking strategy makes a small edit shift every chunk in a document, re-embedding that whole document is the unit of work, which is fine and simple. Chunk-level diffing is rarely worth the complexity.
A document should never be half-updated in the index. Two patterns work:
Either way, make the job idempotent: running the same sync twice must leave the same result, so a crashed run can simply be restarted.
Deleting is not free in an approximate index. The pgvector README notes that vacuuming can take a while for HNSW indexes, suggesting a reindex first, and that queries on an HNSW index can return fewer results than expected "due to dead tuples or filtering conditions in the query." It also explains that with approximate indexes, filtering is applied after the index is scanned, so a tight filter on top of an index full of stale rows can starve the result set. If you filter on "current version only", test retrieval at your real filter selectivity, and schedule vacuum and reindex maintenance. Other vector databases have their own compaction behaviour; read the docs for yours. For the wider storage decision see pgvector vs a dedicated vector database.
Sync reduces staleness; it cannot eliminate it, because there is always a gap between a source change and the next sync. Add defences at answer time:
source_updated_at and indexed_at on
every chunk and pass the date into the prompt context.superseded_by field in your manifest.Add freshness cases to your evaluation set, as described in LLM evals in CI:
Answer three questions for each source you index: how does a change reach the index, how does a deletion reach it, and how would you know if either failed? If you cannot answer the second one, start there, because deletions are what simple "add new files" pipelines miss. Then write a freshness target per source so the engineering effort matches the cost of a stale answer.
If you are building a retrieval layer that has to stay correct as content changes, see how we approach AI SaaS development and get in touch.
Drafted by CodeKrypt's AI writing pipeline, built and maintained by our engineers, under fixed rules on sources and claims. How we write
How to plan an embedding model migration: why vectors from different models cannot be mixed, a blue-green re-indexing pattern, cost drivers and a cutover checklist.
How to pick a RAG chunking strategy: fixed-size vs structure-aware splitting, chunk size and overlap trade-offs, and how to test the choice on your own documents.
Should your AI product use pgvector or a dedicated vector database? The real decision points: scale, filtering, operations and migration cost, with limits taken from the pgvector docs.