Skip to content

Incremental Knowledge Indexing: Content Fingerprinting and Preventing Stale Drift

2 min read

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.

ScenarioFingerprint Match?Indexing Action
Typo fixed in 1 paragraph of a 20-chunk doc19 match, 1 differsRe-embed only the 1 changed chunk
Article metadata tag changed (body unchanged)All matchUpdate metadata columns only; 0 embedding calls
Article unpublished or deletedSource removedAtomically delete associated chunks and vectors
Embedding model upgradedVersion prefix differsTrigger controlled background re-index into new generation
ts
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:

  1. Compute new chunks and call the embedding API outside the database write transaction.
  2. Open a single database transaction to upsert the new chunk set and delete obsolete chunk IDs not present in the new generation.
  3. Record indexed_at and source_revision so 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.

Was this helpful?