esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • AI papersPages
  • Interview KitPages
  • Book a callContact
  • Download ResumeContact
Let’s talk

I’ll build the agent for it.

How Do You Keep the Index Fresh?

How to keep an AI search index of your documents up to date: re-index only what changed, remove what was deleted and rebuild safely, for your AI interview.

In short

You re-index only what changed: new and edited documents are embedded again, and deleted ones are removed. Sync on a schedule or when files change, and when the embedding model changes, rebuild the whole index beside the old one.

11 min readIntermediateCommon · estimateFacts checked 26 November 2026

Say it out loud

Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.

An index goes stale when the files behind it change and the index doesn't. So I don't rebuild everything each time. A sync job compares each file with the last run, re-embeds the new and edited ones, and removes the deleted ones. It runs on a timer, or straight away when a file changes. When the embedding model changes, I build a second index beside the old one, test it on fixed questions, and switch only when it passes. That way customers never get half-updated answers.

What does keeping the index fresh mean, in plain words?

RAG, short for retrieval-augmented generation, means the bot looks up passages from your documents before it answers. Those passages come from an index: a searchable store where each piece of text is kept as an embedding, a list of numbers that stands for its meaning.

Think of a new hire who copies the leave policy into a cheat sheet on day one. When HR changes the rules, the sheet is wrong until someone updates it, and the hire keeps quoting the old rule with confidence. An index behaves the same way. A made-up case: a mid-size insurer's claims assistant quoted last year's deductible (the amount the customer pays first) because the new rule sat in a PDF nobody re-indexed. Keeping the index fresh means keeping that copy in step with the source, without rebuilding everything each time.

Key words

Index
The searchable store the bot looks in, built from your documents.
Embedding
A list of numbers, also called a vector, that stands for the meaning of a piece of text.
Chunk
A short piece of a document, the unit that gets embedded and stored.
Sync
A job that brings the index in line with the source files.
Stale
Out of date: the index no longer matches the files it came from.

How do you find what changed?

Each stored file gets a record of its last version. That is usually a last-modified timestamp from the file store, or a fingerprint, a short code made from the text, so any edit changes it. Each sync run compares today's files with those records and sorts them into four groups: new, edited, deleted and unchanged.

  • “Syncing is incremental, so Amazon Bedrock only processes added, modified, or deleted documents since the last sync.”

    Amazon Bedrock docs

  • “It detects new and updated files and metadata through built-in change detection.”

    Microsoft Learn, blob indexing

One sync run

Your documents

policies, FAQs, claim rules

Spot what changed

compare with the last run

Only the changes

Re-embed new and edited

new text becomes new vectors

Remove deleted

withdrawn text leaves the index

Search index

unchanged files are kept as they are

Current answer

the bot quotes the new rule

  1. 1The job reads the file list as it is today.
  2. 2New, edited and deleted files go on to the work step. Unchanged files are skipped.
  3. 3Fresh vectors are written, and deleted files are removed from the index.
  4. 4The bot searches the updated index and quotes the new rule.
One sync run: the job reads today's files, works out what changed, re-embeds only the new and edited ones, and drops the deleted ones. Unchanged files are left alone, so the run stays quick.

Worked example, with made-up numbers: the insurer keeps 18,000 documents, and about 150 change in a week. A full rebuild re-embeds all 18,000 and takes most of a night. The incremental run touches only the 150 and finishes in minutes, and the bot is current by the morning. Here is the decision in a small Python sample, with made-up file names from a bank.

Python
# A simplified sync job. Each file has a version tag that changes when its text changes.
# Compare today's tags with the last run, and touch only what differs.
last_run = {"card-fees-2026.md": "rev3", "leave-policy.md": "rev7", "dispute-process.md": "rev2", "branch-hours-old.md": "rev1"}
today = {"card-fees-2026.md": "rev4", "leave-policy.md": "rev7", "dispute-process.md": "rev2", "chargeback-faq.md": "rev1"}

new = [f for f in today if f not in last_run]
changed = [f for f in today if f in last_run and today[f] != last_run[f]]
removed = [f for f in last_run if f not in today]
skipped = [f for f in today if f in last_run and today[f] == last_run[f]]

print("Re-index (new):", ", ".join(new) or "none")
print("Re-index (changed):", ", ".join(changed) or "none")
print("Remove from index:", ", ".join(removed) or "none")
print("Skip, no change:", ", ".join(skipped) or "none")

Output

Re-index (new): chargeback-faq.md
Re-index (changed): card-fees-2026.md
Remove from index: branch-hours-old.md
Skip, no change: leave-policy.md, dispute-process.md

How often should the index refresh?

  • Scheduled

    A timer, hourly or nightly

    Simple and cheap to run. Answers can lag behind the source by up to one full interval.

  • Event-driven

    A change starts the sync

    A file save triggers the job, so answers catch up soon after the change. More moving parts to run and watch.

  • On demand

    A person or job asks for it

    Good for a one-off large load or a source that rarely changes. Easy to forget, so pair it with a timer.

  • “To maintain current information for retrieval, asynchronously update the documents and update embedding representation of the documents.”

    AWS, what is RAG

  • “You can do this through automated real-time processes or periodic batch processing.”

    AWS, what is RAG

Microsoft's indexer for blob storage (cloud file storage) offers two refresh options: on a schedule or on demand. Match the speed to the harm of a wrong answer. A fee rule can wait an hour. A fraud rule or a safety instruction may need a change-triggered sync.

Tip

Asked how often? Don't say real time by default. Ask how long a wrong answer can stay live, then set the sync speed to match.

What about deleted files and a new embedding model?

Deletions are the step people forget. If a withdrawn policy stays in the index, the bot quotes it with confidence. Amazon Bedrock removes a deleted document from its vector store (the database that holds the embeddings) on the next sync. Azure's indexer can spot deletions through native soft delete (the file is marked deleted rather than erased) or a custom metadata field (an extra label on each file), so check which one your tool uses. A new embedding model is the big change. Old and new vectors don't mix, so the whole index has to be rebuilt with the new model. Build it beside the live one, test it, then switch. Keep the old index for a few days so you can roll back.

Swapping to a new embedding model

Live index, old model

old vectors keep serving answers

Build index beside it

every chunk re-embedded once

Check before switching

Fixed test questions

same questions for both indexes

Compare the answers

look for changed facts

Point the bot at new

keep the old index for rollback

  1. 1Every chunk is copied and embedded again with the new model.
  2. 2The new index is tested on the same questions before anyone uses it.
  3. 3Once it passes, the app points at the new index, and the old one stays ready for a rollback.
Changing the embedding model without downtime: the live index keeps serving while the new one is built and tested. The switch happens only after the checks pass, and the old index stays ready to roll back.

How would you stop an old policy answer reaching customers?

A customer asks about the deductible on a policy that changed on Monday. The sync ran on Tuesday, but the bot still quotes the old figure. Here is how I would stop that.

  1. 1

    Stamp each chunk with its date

    Store the source file's version and date with every chunk, so each answer can show which rule it came from.

  2. 2

    Alert on lag

    If a source changed but the index did not sync within its window, the owner gets a message. A sync that fails quietly is the one to watch for.

  3. 3

    Test the changed rules

    Keep test questions for each policy. After every sync, the new figure must appear and the old one must not.

  4. 4

    Show the date to the customer

    Put the source date in the reply, so a stale answer is visible to the customer and to the team.

Customers ask in plain words, so the test set does too. A typical question is "What is my excess on the new policy?" and the answer must carry the new figure.

What does the interviewer want to hear?

A strong answer covers

  • The index is a copy of the source, so it goes stale.
  • Sync only what changed: detect it, re-embed it, and remove deletions.
  • Pick the refresh timing by how harmful a wrong answer is.
  • Deletions need their own handling, or withdrawn text keeps answering.
  • A new embedding model means a full rebuild beside the old index, then a switch.
  • Test with fixed questions after every sync.

Common traps

  • Trap"Just rebuild the whole index every night."

    BetterFine when the document set is small. At scale it's slow and costly, so re-embed only what changed, and rebuild in full only for a new model.

  • Trap"Real time is always the best choice."

    BetterReal-time sync adds moving parts and cost. Match the speed to how fast a wrong answer causes harm.

  • Trap"Adding new documents is enough."

    BetterEdited and deleted files need handling too, or old and withdrawn text keeps being quoted.

Can you spot the stale index?

Spot the gap

Your bot runs a nightly sync. Which setup can still serve a withdrawn policy the next morning?

Quick check

An insurer changes its embedding model. What is the safest way to switch?

Can you answer these from memory?

Flash cards · tap a card to flip it

1 / 6

What will they ask next?

  1. Q133What are common RAG failure modes?11 min
  2. Q140How do you enforce access control in RAG?11 min
  3. Q145How do you cache RAG results?Coming soon
  4. Q150How would you design RAG for 10 million documents?12 min
  5. Q155Build a minimal RAG pipeline.13 min
  6. Q281Fine-tune vs RAG vs prompting: when to use which?10 min

Last updated on 26 November 2026

Keeping a RAG index in step with live documents?

I design and build AI products and agents, including the sync jobs, deletion handling and checks that keep their search current. Book a short call and tell me how often your documents change.