Incremental Knowledge Indexing: Content Fingerprinting and Preventing Stale Drift
Knowledge bases change constantly: pricing updates, seasonal promotions expire, and support articles get rewritten. Re-embedding an entire corpus on every edit wastes money and risks rate-limit spikes, while skipping re-indexing causes stale knowledge drift where the AI quotes outdated terms.
Content Fingerprinting Pattern
Assign every document and every chunk a deterministic cryptographic hash (such as SHA-256) computed over normalized text plus embedding configuration (embedding_model, dimensions, chunker_version). Before calling the embedding API, compare the new fingerprint against the stored fingerprint.
| Scenario | Fingerprint Match? | Indexing Action |
|---|---|---|
| Typo fixed in 1 paragraph of a 20-chunk doc | 19 match, 1 differs | Re-embed only the 1 changed chunk |
| Article metadata tag changed (body unchanged) | All match | Update metadata columns only; 0 embedding calls |
| Article unpublished or deleted | Source removed | Atomically delete associated chunks and vectors |
| Embedding model upgraded | Version prefix differs | Trigger controlled background re-index into new generation |
import { createHash } from "node:crypto";
export function computeChunkFingerprint(input: {
model: string;
chunkerVersion: string;
normalizedText: string;
}): string {
return createHash("sha256")
.update(`${input.model}|${input.chunkerVersion}|${input.normalizedText.trim()}`)
.digest("hex");
}
Atomic Swap vs Partial Writes
Never delete all existing chunks for a document before computing the new embeddings. If the embedding provider times out midway, the document disappears from search entirely. Instead:
- Compute new chunks and call the embedding API outside the database write transaction.
- Open a single database transaction to upsert the new chunk set and delete obsolete chunk IDs not present in the new generation.
- Record
indexed_atandsource_revisionso monitoring alerts if indexing lag grows beyond your SLA.
Handling Crawled Web Pages
For external URLs, respect HTTP conditional requests (ETag, If-Modified-Since), normalize boilerplate before hashing so rotating timestamps or ad banners do not trigger spurious re-embeds, and handle 404/410 responses by retiring stale pages cleanly.
Next: finish the retrieval pipeline by preventing hallucinations at generation time in Citations, Abstention Policies, and Hallucination Guardrails.