Home / Insights / Generative AI and LLMs
Generative AI and LLMs
Keeping a RAG Knowledge Base Fresh: Sync, Versioning and Deletion That Hold Up in Production
A retrieval-augmented assistant is only as current as its index. This guide explains how to detect changes in source systems, re-index incrementally, version your chunks and embeddings, and make sure deleted or restricted documents actually leave the index.
Key takeaways
- Stale and deleted content is the most common way a working RAG pilot loses trust in production; design sync and deletion before you tune prompts.
- Use each source’s change feed (delta tokens, change lists, modification timestamps) for incremental sync, and schedule periodic full reconciliation because change feeds can reset or miss items.
- Treat deletion as a first-class event with its own pipeline and a measurable deadline, and verify it by querying the index, not by trusting the connector.
- Version the index, not just the documents: record which parser, chunking rules and embedding model produced each chunk so you can rebuild or roll back safely.
- Publish freshness metrics, such as sync lag, failed documents and deletion lag, to the owners of the content, not only to engineering.
On this page
- Why freshness is the problem that sinks production RAG
- Detecting change: the sync patterns and when to use each
- Re-indexing incrementally without corrupting the index
- Versioning documents, chunks and the index itself
- Deletion: making removed content actually disappear
- Operating the sync: monitoring, costs and ownership
- Freshness checklist before you go live
- Frequently asked questions
- Sources and methodology
Most retrieval-augmented generation (RAG) pilots are built on a snapshot: someone exports a folder of documents, indexes it and demonstrates good answers. Then the policies change, a contract is superseded, a confidential file is removed from SharePoint, and the assistant keeps quoting the old version with a confident citation. Users notice quickly, and trust is hard to win back.
This guide is for CTOs, architects and knowledge-management leads who are moving a RAG assistant from pilot to production. It focuses on one narrow problem: keeping the index in step with its sources. It covers how to detect changes, how to re-index without rebuilding everything, how to version what you index, and how to make deletion reliable. It draws on how we design ingestion for our enterprise knowledge search projects, where scoping always includes document sources, access rules and freshness requirements. For the earlier steps of preparing documents and permissions, see our ingestion and permissions checklist.
Why freshness is the problem that sinks production RAG
The original RAG paper by Lewis et al. describes a model with two kinds of memory: the knowledge in the model’s parameters, and a non-parametric memory in the form of a dense vector index accessed by a retriever. The authors list updating knowledge and providing provenance as open problems for parameter-only models. That is the core business appeal of RAG: you update the index, not the model.
The catch is that the index is now a copy of your content, and every copy drifts. In practice, freshness failures fall into four groups:
- Missed updates. A document changes in the source but the index still holds the old chunks.
- Orphaned chunks. A document is deleted or moved, but its chunks remain retrievable.
- Permission drift. Access to a document is narrowed, but the index still carries the old access list.
- Mixed generations. Part of the index was built with one parser or embedding model and part with another, so retrieval quality varies in ways nobody can explain.
Each of these produces a wrong but well-cited answer, which is worse than no answer. Permission drift and orphaned chunks are also data protection issues, which is why our separate guide on permission-aware enterprise search treats access changes as a sync problem as much as a retrieval problem.
Detecting change: the sync patterns and when to use each
There are four practical ways to learn that something has changed in a source system. Most production systems combine at least two.
Change feeds and delta tokens
Many enterprise platforms provide an API that returns only what has changed since a saved token. Microsoft’s Graph delta query documentation describes this pattern: you page through results until you receive a delta link, store it, and call it later to receive only changes. Deleted items are returned with an @removed marker, and the documentation distinguishes soft-deleted items from permanently deleted ones. It also warns that the same change can be replayed, that ordering is not guaranteed, and that a token can expire or reset, forcing a full resync. Google’s Drive API guide to tracking changes follows a similar shape with a start page token, a changes list and a new start page token to store for the next poll.
Push notifications plus pull
Webhooks or watch channels tell you that something changed, so you do not have to poll constantly. Google notes that its change notifications do not contain change details, so you still call the changes list afterwards. Microsoft recommends combining change notifications with delta queries for high-volume scenarios. Treat notifications as a trigger, never as the record of what changed.
Modification timestamps
Where no change feed exists, compare last-modified timestamps or content hashes against what you indexed. Azure AI Search indexers, for example, use a blob’s last-modified timestamp to re-index changed content, according to Microsoft’s guide to changed and deleted blobs. Timestamps are simple, but they cannot see deletions on their own.
Full reconciliation
Periodically list every document the source says exists and compare it with what the index holds. It is slow, but it is the only method that catches everything the other methods miss, including items lost during a token reset.
| Pattern | Detects updates | Detects deletions | Latency | Main weakness |
|---|---|---|---|---|
| Delta tokens / change feed | Yes | Usually, if the API reports them | Minutes | Token expiry and resets; replays |
| Push notification + pull | Yes | As per the underlying feed | Near real time | Missed notifications; extra moving parts |
| Timestamp or hash comparison | Yes | No, not without a listing | Depends on schedule | Blind to deletes and to permission changes |
| Full reconciliation | Yes | Yes | Hours | Cost and load on source systems |
A sensible default is a change feed for routine sync, notifications where latency matters, and a scheduled full reconciliation, for example weekly, as a safety net.
Re-indexing incrementally without corrupting the index
Once you know a document changed, the pipeline has to replace its chunks cleanly. The most common bug we see is appending new chunks without removing old ones, so the index holds both versions and retrieval returns whichever happens to score higher.
Use stable identifiers
Give every source document a stable ID that survives renames and moves, ideally the source system’s own ID rather than a file path. Derive chunk IDs from the document ID plus chunk position or a content hash. When a document changes, delete all chunks for that document ID, then insert the new set, inside one logical operation.
Make every step idempotent
Change feeds can replay the same event, so processing a change twice must produce the same result as processing it once. Upserts keyed on chunk ID, and “delete all chunks for document then insert” operations, are naturally idempotent.
Skip unchanged work
Store a content hash for each document and each chunk. If the source reports a change but the extracted text hash is identical, for example because only a metadata field was touched, update the metadata and skip re-embedding. This keeps embedding costs and API rate limits under control.
Handle metadata-only changes separately
A change in permissions, owner, classification label or expiry date should update the chunk metadata used for filtering, without re-embedding. Permission changes in particular should take the fastest path through the pipeline.
- Receive change event and look up the stable document ID.
- Fetch current content and metadata from the source.
- Compare content hash; if unchanged, update metadata only.
- If changed, parse, chunk and embed the new version.
- Delete existing chunks for the document ID and insert the new set.
- Record the document version, pipeline version and timestamp in the sync ledger.
Versioning documents, chunks and the index itself
Versioning in a RAG system has three layers, and teams usually only think about the first.
Document versions
Decide whether the assistant should ever answer from superseded versions. For policies and contracts, the usual answer is no: only the current approved version is retrievable, while older versions stay in the source system’s own history. For technical documentation covering several product releases, you may need multiple versions in the index, each tagged with the product version it applies to and filtered at query time.
Chunk lineage
Each chunk should record the document ID, document version or modification time, the parser and chunking configuration used, and the embedding model and version. Without this lineage, you cannot answer simple questions such as “which chunks were produced by the old PDF parser?”
Index generations
Changing the embedding model, chunk size or parser changes the meaning of the whole index. Vectors from two different embedding models are not comparable, so you cannot mix them in one index. Treat these changes as a new index generation:
- Build the new generation alongside the live one, using the same sync ledger.
- Keep both generations receiving changes during the build so the new one does not start stale.
- Run your evaluation set against both and compare retrieval and answer quality.
- Switch traffic with an alias or configuration flag, and keep the old generation for a defined rollback period.
- Retire the old generation, and make sure deletions processed during the overlap reached both.
That evaluation step depends on having a stable test set; our article on building a test set for knowledge search covers how to create one.
Deletion: making removed content actually disappear
Deletion deserves its own design because it is where freshness meets legal risk. A document can leave the index for several reasons: it was deleted, archived, moved out of scope, restricted to fewer people, or contains personal data subject to an erasure request.
Why deletion is easy to get wrong
- Some sync methods do not see deletions at all. Microsoft states that Azure AI Search indexers do not detect deletions in blob storage unless you configure a deletion detection policy, and that documents deleted before the policy existed remain in the index.
- Change feeds report deletions differently: Graph distinguishes soft and permanent deletion, and a restored item reappears as a new item.
- Derived copies exist: caches of previous answers, conversation logs that quoted the document, evaluation sets and analytics exports.
Legal context
Under the GDPR, people have a right to have personal data erased in certain circumstances, and controllers are expected to respond to requests without undue delay and at the latest within one month, as set out in the Regulation’s text on EUR-Lex (including Recitals 59 and 65). The same regulation’s recitals expect inaccurate data to be rectified or deleted and time limits to be set for erasure or periodic review. If your knowledge base contains personal data, your RAG index and its caches are in scope. Take legal advice on your specific obligations; the engineering point is that you need a reliable, provable path.
A deletion pipeline that you can prove
- Treat every deletion, restriction or out-of-scope move as an event with a document ID and a reason.
- Remove all chunks for that document ID from every live index generation, and purge any answer cache entries that cited it.
- Record the deletion in the sync ledger with a timestamp.
- Verify by querying the index for the document ID and by running a search for distinctive text from the document; both should return nothing.
- Run full reconciliation regularly to find orphaned chunks whose source no longer exists, and delete them.
- Report deletion lag, the time between source deletion and verified removal, as a tracked metric with an agreed target.
Operating the sync: monitoring, costs and ownership
Sync is not a one-off build. It is a service that needs monitoring and an owner, and its costs scale with content volume and change rate.
Metrics worth publishing
| Metric | What it tells you | Who should see it |
|---|---|---|
| Sync lag per source | How old the newest indexed change is | Engineering and content owners |
| Failed documents | Files that could not be parsed or embedded | Content owners, to fix formats |
| Deletion lag | Time from source deletion to verified removal | Data protection and security |
| Orphaned chunks found by reconciliation | How much the incremental path is missing | Engineering |
| Index generation and age | Which pipeline version is live | Engineering and product |
Cost drivers
- Embedding calls scale with changed content, so hashing to skip unchanged text matters.
- Source API limits constrain how fast you can sync and how often you can reconcile.
- Parallel index generations during a model change temporarily double storage and embedding work.
- Parsing failures cost staff time; scanned and complex documents need OCR and manual review.
Ownership
Give each source a named content owner who receives the failed-document and freshness reports. Engineering can make sync reliable, but only content owners can decide that an outdated policy should be archived rather than indexed.
For example, a 200-person professional services firm indexing SharePoint and a ticketing knowledge base might run delta sync every few minutes, a nightly permission refresh and a weekly full reconciliation, with deletion lag reported monthly to its data protection lead. This is an illustrative configuration, not a benchmark.
Freshness checklist before you go live
- Every source has a documented sync method, schedule and fallback full reconciliation.
- Documents use stable source IDs, and chunk IDs derive from them.
- Change processing is idempotent and tolerates replays and out-of-order events.
- Content hashes prevent unnecessary re-embedding.
- Permission and metadata changes take a fast path that does not wait for re-embedding.
- Each chunk records document version, parser, chunking configuration and embedding model.
- Model or chunking changes create a new index generation with evaluation before switch-over.
- Deletion is an explicit event, applied to all generations and caches, and verified by query.
- Deletion lag and sync lag have agreed targets and are reported.
- Content owners receive failed-document reports and decide what is archived.
If you can tick every item, your assistant will degrade gracefully when sources change. If you cannot, fix sync before adding new sources or features.
Frequently asked questions
How often should a RAG index sync with its sources?
It depends on how quickly wrong answers cause harm. Policies, prices and permissions usually justify near real-time or frequent delta sync, while archives can sync daily. Whatever the routine schedule, add periodic full reconciliation because change feeds can reset or miss items.
Do we need to re-embed everything when we change embedding model?
Yes. Vectors from different embedding models are not comparable, so a model change means building a new index generation. Build it alongside the live index, keep both receiving changes, evaluate both on the same test set, then switch with a rollback window.
Is deleting a file from SharePoint or Google Drive enough to remove it from the assistant?
Not automatically. The deletion has to reach your index through a change feed, deletion policy or reconciliation, and cached answers and logs may still hold copies. Verify removal by querying the index for the document ID and distinctive text.
How do we handle erasure requests that affect the knowledge base?
Treat them as deletion events applied to every index generation, answer cache and derived dataset, record them in a ledger and verify removal. GDPR expects responses without undue delay and at the latest within one month; take legal advice on your specific obligations.
Should the assistant ever answer from old document versions?
Usually not for policies and contracts, where only the current approved version should be retrievable. For product documentation covering several releases, keep multiple versions in the index tagged by applicable version and filter at query time.
Sources and methodology
Guidance reflects PoliteTech delivery experience. The external references below informed specific points in this article.
- Lewis et al.: Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (arXiv, 2020) — accessed 9 November 2026. Definition of RAG as parametric plus non-parametric memory and the problems of updating knowledge and provenance.
- Microsoft Learn: Use delta query to track changes in Microsoft Graph data — accessed 9 November 2026. Delta and next links, @removed markers for soft and permanent deletes, replays, ordering, token expiry and full-resync behaviour.
- Google for Developers: Retrieve changes (Drive API) — accessed 9 November 2026. Start page tokens, changes list paging and that push notifications do not include change details.
- Microsoft Learn: Change and deletion detection using indexers for Azure Storage — accessed 9 November 2026. Indexers detect changes via last-modified timestamps but need a deletion detection policy; deletions before the policy remain indexed.
- EUR-Lex: Regulation (EU) 2016/679 (GDPR) — accessed 9 November 2026. Recitals on responding to requests within one month, the right to erasure, and rectifying or deleting inaccurate data.
Related reading
Continue your research
Is your knowledge assistant still answering from documents you have already changed or deleted?
We can audit your sources, sync pipeline and deletion path and show where stale or restricted content can still surface in answers.
