Lesson 21 / 28
Updates, Deletes and Freshness
Keep the index in step with changing documents.
Stale vectors give stale answers
Documents change, so the index must too. Give each chunk a stable ID and a source document ID and content hash; on a change, re-chunk and re-embed only changed documents and replace their old chunks (delete by source ID, then insert). Handle deletions and permission changes promptly, since a removed or restricted document must stop being retrievable. Some ANN structures handle deletes lazily (marking entries as deleted and cleaning up during maintenance), and heavy churn may require periodic rebuilds or compaction. Keep version and effective-date metadata to prefer current content, and monitor index lag (how long a change takes to become searchable). For large batch updates, build a fresh index and switch atomically.
Monitor index lag
Measure how long it takes for a new or deleted document to appear or disappear in results, and alert if it grows.
Quick check: How should a changed document be updated in the index?
- Add the new chunks and keep the old ones
- Re-embed it and replace its old chunks by source document ID
- Rebuild nothing and hope
- Edit the vector numbers by hand
Answer
Re-embed it and replace its old chunks by source document ID — Leaving old chunks behind returns outdated, contradictory results.