skip to content

Ingestion Pipelines

Keeping a RAG index in step with sources that keep changing: syncing edits and deletes, re-embedding after a model switch, and bounding lag. Interviewers ask what happens on day two.

part ofRetrieval-augmented generation (RAG)read it →
on this pageshow

explore

questions

27

In a nightly-reindexed RAG pipeline, why build chunk IDs from the source document ID plus position, not random UUIDs or chunk-text hashes?

level: juniorimportance: must knowfreq 55%

answer

  1. what a second run writes
  2. overwrite instead of append
  3. the document is the unit you delete
  4. stable source identifier, not the URL
  5. source prefix + document ID + ordinal

basics

~20 s

Deterministic IDs from the document ID plus chunk position make a re-run overwrite the same records instead of adding copies, and let the pipeline name and delete a document's whole chunk set. Random IDs duplicate every run; text hashes lose the document link.

solid answer

~50 s

A nightly re-index has to be safe to run again. If each chunk gets a random UUID, every run inserts a fresh copy of every chunk, so an unchanged page appears twice after two nights and retrieval fills its top results with duplicates. An ID like `docs:4812#0003` (source, the source system's immutable document ID, chunk ordinal) is the same on every run, so an upsert overwrites in place and the write is idempotent. It also makes the document the addressable unit: with the previous chunk count or ID list you can name every chunk a page owns and delete them. A hash of the chunk text is deterministic too, but it ties the record to its words rather than its document, so identical boilerplate in two pages collapses into one record and an edit leaves the old record behind under a different ID.

go deeper

for a junior

Recall that the ingestion job runs again and again, and that a random ID turns every run into a fresh insert. Say what a second run does under each scheme.

for a middle

Explain why the document, not the chunk text, must anchor the ID, and how a stable source identifier plus a position lets you name and delete a page's chunks.

for a senior

Show the edges: renames under URL-based IDs, cross-source collisions, stores that only accept UUIDs, and the orphans positional IDs still leave when a page shrinks.

for a principal

Treat the ID scheme as a contract every connector must honour; a team that lets each source invent its own IDs pays for it in duplicates and undeletable chunks.

## The problem a chunk ID has to solve A **retrieval index** for retrieval-augmented generation (RAG) stores each source document as many **chunks**: passages of text, each with an embedding vector and a payload of metadata such as the document's title and URL. A nightly ingestion job reads every page of, say, a product-documentation site, splits each page into chunks, embeds them and writes them to a vector store. The job runs again tomorrow, and the night after. The chunk's **record ID** decides what that second run does. Many vector stores offer an **upsert**: write this record, replacing any existing record with the same ID. Upsert is only as safe as the ID you feed it. The requirement is simple to state: running the job twice over the same sources must leave exactly the records one run would have left. ## What each ID scheme does on a re-run | ID scheme | Unchanged page, second run | Page edited | Deleting the page later | |---|---|---|---| | Random UUID per chunk | Every chunk inserted again: duplicates | New chunks added beside the old ones | Needs a `doc_id` field in every payload, or a separate record of the IDs it got | | Hash of the chunk text | Same IDs, overwritten: fine | Changed chunks get new IDs; old ones stay | Shared boilerplate chunks belong to several pages at once | | Source + document ID + position | Same IDs, overwritten: fine | Same positions overwritten in place | Every ID is derivable from the document ID and its chunk count | - **Random IDs** make every write an insert. Two runs give two copies of every chunk; thirty runs give thirty. Retrieval returns near-identical passages for the top results, and nothing in the IDs tells the copies apart. - **Text-hash IDs** are deterministic, so an unchanged chunk is not duplicated. But the ID describes the words, not their owner. A legal footer or a "Getting started" paragraph that appears on fifty pages hashes to one ID, so fifty pages fight over one record and its metadata, and deleting one page can remove a chunk the other forty-nine still need. When a page is edited, its changed chunks hash to new IDs and the old records stay behind. - **Document ID plus position** ties every chunk to the document it came from. The same page always produces the same IDs, so re-runs are idempotent, and the pipeline can enumerate a page's chunks from its ID and how many chunks it had. ## Choosing the document part of the ID The document ID carries most of the weight, and it must be **stable for as long as the document exists**: 1. Use the source system's own **immutable identifier** for the page (a page number or object ID), not its URL, path or title. URLs change when a page is moved or renamed, and a URL-based ID turns a rename into a delete plus an add, with the old chunks left behind if the delete is missed. 2. **Prefix the source** (and the tenant, in a multi-tenant index). Two sources can both number their pages from 1; without a prefix, page 1 of one source overwrites page 1 of the other. 3. **Zero-pad or delimit the ordinal** so `#0003` is unambiguous and sorts in order, which makes a range of positions easy to name. 4. If the store only accepts UUIDs or integers, derive a **name-based UUID** (version 5 hashes a namespace plus a name) from the readable string. The same string always gives the same UUID. Keep the readable form and the document ID in the payload, so you can debug and delete by document. ```json { "id": "docs-site:4812#0003", "payload": { "doc_id": "docs-site:4812", "position": 3, "title": "Configuring alerts" } } ``` (Field names are illustrative, not any store's schema.) ## What positional IDs do not solve on their own Deterministic IDs make a re-run idempotent for documents that did not change shape. They leave two gaps that the rest of a re-indexing design closes: - **A shrinking document.** If a page goes from twelve chunks to nine, the upsert overwrites positions 0 to 8 and never touches 9 to 11. Those three records are **orphans**. The fix is to remember each document's previous chunk set and delete what the new run did not write. - **An insert near the top.** A positional ID changes meaning when text is inserted early in a page, because every later chunk shifts down one position and is rewritten. Keeping one edit's rewrite small is a chunk-boundary design question, separate from the re-run safety covered here. Idempotency in general (deduplication stores, idempotency keys on requests) is a wider distributed-systems subject. The point here is narrower: a deterministic, document-anchored chunk ID is what makes this one pipeline's writes safe to repeat. ## How interviewers probe it - "What happens on the second run?" is the opening: random IDs duplicate. - "Why not hash the text?" tests whether you see that a hash identifies content, not ownership. - "The page was renamed; what happens?" tests the stable-identifier point. - "How do you delete a page's chunks?" checks that you can name them all from the ID scheme plus a stored count or ID list.

  • The vector store only accepts UUIDs as record IDs. How do you keep IDs deterministic?
    Build the readable string first, such as `docs-site:4812#0003`, then derive a name-based UUID (version 5) from a fixed namespace plus that string. The same string always yields the same UUID, so upserts still overwrite. Store the readable string and the document ID in the payload so you can debug a record and delete by document.
  • Why prefix the source or tenant to the document ID?
    Different sources often number documents independently, so page 4812 can exist in two of them. Without a prefix their chunks share IDs and each run overwrites the other source's chunks. The prefix makes IDs globally unique and lets you scope a delete or a cleanup to one source.
  • Do positional IDs make an edit near the top of a page cheap to re-index?
    No. An inserted paragraph shifts every later chunk by one position, so every later record is rewritten even if its text barely moved. Positional IDs buy re-run safety and the ability to name a document's chunks; keeping one edit's rewrite local is a separate chunk-boundary design choice.

  • Random UUIDs are fine because the store deduplicates identical vectors.
  • Use the page URL as the document ID; it never changes.
  • A hash of the chunk text gives every chunk a unique owner.
  • Upsert makes any ID scheme safe to re-run.
  • Positional IDs keep an edit near the top of a page cheap.
open as a page

A re-embedding backfill dies at 60% — what must its progress record hold so a restart neither re-bills finished chunks nor mixes model versions?

level: middleimportance: must knowfreq 50%

basics

~20 s

One record per chunk keyed by chunk ID and the exact pinned model revision, written only once the vector is durable, so a restart re-embeds just the chunks with no record at the new version.

open as a page

When re-embedding a 40-million-chunk retrieval corpus under a provider's tokens-per-minute limit or on your own accelerators, how do you estimate wall-clock time and spend?

level: middleimportance: must knowfreq 46%

basics

~20 s

Count the corpus in the new model's input tokens, divide by the throughput you can really use (the spare rate-limit share or measured accelerator rate), and check the store's write rate; spend is tokens times price, or accelerator-hours times rate.

open as a page

A RAG source page shrinks from 12 chunks to 9 and ingestion upserts by chunk ID: what is left behind, and what stops it?

level: middleimportance: must knowfreq 58%

basics

~20 s

Chunks at positions 9 to 11 stay in the index as orphans with the page's old text, because an upsert only writes the IDs it is given. Record each document's chunk IDs and delete the ones the new run did not write.

open as a page

When should an ingestion connector sync a wiki, shared drive or ticket tracker by full crawl, change feed or webhook, and why keep a crawl?

level: middleimportance: must knowfreq 58%

basics

~20 s

Use a source's change feed where it offers one, webhooks as a low-latency trigger to fetch, and a scheduled crawl where neither exists; keep a periodic reconciliation crawl because feeds expire, webhooks drop and some changes never appear in either.

open as a page

In a RAG ingestion pipeline fed by a polled HR handbook, a webhook-fed incident queue and a code repository indexed on merge, where does edit-to-retrievable lag go, stage by stage?

level: seniorimportance: must knowfreq 50%

basics

~20 s

Lag is detection plus parse plus embed plus write. The polled handbook is dominated by waiting for its next poll, the incident queue by embedding-queue wait under load, and the code repository by embedding the many chunks one merge produces.

open as a page

When a page is removed from a documentation site and the crawl lists only pages that exist, how does a RAG index find and remove its chunks?

level: seniorimportance: must knowfreq 50%

basics

~20 s

Keep a per-source registry of indexed documents; after a complete listing, documents in the registry but not the listing were removed, so delete each one's whole chunk set. Never diff a partial listing, and hold any run deleting an unusual share.

open as a page

How does an ingestion connector turn a source's inherited space, folder and share-link permissions into chunk access lists, and catch permission changes that never bump the modified time?

level: seniorimportance: must knowfreq 54%

basics

~20 s

Compute each document's effective access from its ancestors and restrictions, store it as user and group identifiers on every chunk, fail closed when unreadable, and catch permission-only changes with permission events and a sweep comparing access-list hashes.

open as a page

Why should a RAG assistant tell users when a cited source is behind, and what must its ingestion pipeline record to do that?

level: juniorimportance: should knowfreq 35%

basics

~20 s

A stale answer reads as fluent and well cited as a fresh one, so users rarely spot it. The pipeline must record, per source, the time up to which changes are confirmed indexed, and per chunk its source's modified time.

open as a page

What does turning a ticket thread or wiki page into clean text for a retrieval index involve, and which source metadata do you keep?

level: juniorimportance: should knowfreq 50%

basics

~20 s

Strip what the source added around the writing (navigation, macros, signatures, quoted replies, bot notes), keep headings, tables and code blocks, and keep metadata to cite, filter and re-sync: source ID, URL, title, path, author, timestamps, status, access list.

open as a page

For chunks in a retrieval index, what do positional, content-hash and heading-path chunk IDs each do when a paragraph is inserted mid-document?

level: middleimportance: should knowfreq 30%

basics

~20 s

Positional IDs renumber every chunk after the insert, so each later ID points at different text; content-hash IDs keep every unchanged chunk's ID and mint one new one; heading-path IDs renumber only inside the edited section.

open as a page

With fixed-size chunking in a RAG ingestion pipeline, why does inserting one sentence near a document's top re-embed almost every chunk?

level: middleimportance: should knowfreq 38%

basics

~20 s

Fixed-size windows cut at fixed offsets, so an insert shifts every later boundary: each chunk after it now holds different text and must be re-embedded. Anchoring cuts on structure or content keeps an edit local to its section.

open as a page

In a RAG ingestion pipeline, why should deletes and permission revocations overtake queued edits, and what makes them cheap to fast-track?

level: middleimportance: should knowfreq 45%

basics

~20 s

A late edit serves stale text; a late delete or revocation keeps serving content that is gone or that a user may no longer see. Both skip parsing and embedding, so a fast lane costs little more than an index write.

open as a page

How does a per-document content hash let a nightly RAG re-index skip unchanged documents, and what does a text-only hash miss?

level: middleimportance: should knowfreq 45%

basics

~20 s

Store a hash of each document's normalised text and skip parsing, chunking and embedding when tonight's hash matches. A text-only hash misses changes that alter the stored chunks without touching the words: metadata, access lists and the pipeline's own parser or chunker version.

open as a page

A document source rejects a week-old sync token from an ingestion connector as expired: how do you recover without emptying or doubling the retrieval index?

level: middleimportance: should knowfreq 46%

basics

~10 s

Keep serving the existing index, take a fresh change position before re-crawling, write every document under its stable source ID, replay changes since that position, then hand documents neither pass saw to delete reconciliation.

open as a page

When an ingestion pipeline re-chunks an edited document, how do you diff the new chunks against the stored ones so only changed chunks are re-embedded?

level: seniorimportance: should knowfreq 28%

basics

~10 s

Fingerprint each new chunk's exact embedding input plus the model version, match fingerprints against the document's stored chunks, reuse vectors for matches, embed only the misses, and retire stored chunks nothing matched.

open as a page

Before cutting over to a new embedding model, how do you prove every current source chunk has a vector from that model, and what gaps can a green job status hide?

level: seniorimportance: should knowfreq 42%

basics

~20 s

Reconcile, per tenant, the current chunk IDs against the vectors the store holds at the new version, then check shape, content hashes and a recomputed sample. A green job can hide skipped errors, misaligned batch results and missing filter metadata.

open as a page

Midway through a re-embedding backfill, the new embedding model rejects or silently truncates chunks the old one accepted — what causes this, and what do you do with them?

level: seniorimportance: should knowfreq 34%

basics

~20 s

The chunks were sized for the old model: the new one may accept fewer input tokens, count tokens differently or validate inputs more strictly. Pre-flight with its tokenizer, record each chunk's status, and decide every oversize chunk before cutover.

open as a page

When a bulk migration floods a RAG pipeline's embedding queue and live incident edits wait hours to become retrievable, how do you protect live freshness?

level: seniorimportance: should knowfreq 42%

basics

~20 s

Live edits waited behind the whole bulk backlog in one shared queue. Tag work by origin, give live edits their own lane with a reserved share of embedding throughput that bulk may borrow when idle, and feed the migration in bounded pages.

open as a page

For a changed page in a RAG index, how do delete-then-insert, write-new-then-delete-old and an atomic generation flip differ in what a query can see mid-update?

level: seniorimportance: should knowfreq 45%

basics

~20 s

Delete-then-insert opens a gap where the page has no chunks; write-new-then-delete-old opens an overlap where both versions are retrievable. Writing a new generation and flipping one active-generation record shows queries the whole old set or the whole new one.

open as a page

During a source outage, webhook deliveries to an ingestion connector were silently dropped: how would you notice, and what backstop catches the missed changes?

level: seniorimportance: should knowfreq 40%

basics

~20 s

Watch signals the deliveries cannot fake: a scheduled canary edit that must arrive, delivery volume against the source's norm, subscription status, and a poll counting edits no webhook reported; that poll and a reconciliation crawl are the backstop.

open as a page

A connector's first crawl of two million wiki pages must share the wiki's API quota with its users and other integrations: how do you budget and order it?

level: seniorimportance: should knowfreq 36%

basics

~20 s

Count requests per page, agree a quota share with the source owner, reserve some for live changes, run faster off-hours, slow down on throttling signals, and crawl the most-used spaces first so the assistant is useful early.

open as a page

For a multi-tenant retrieval index moving to a new embedding model, how would you set the policy for cutting tenants over one at a time and routing each tenant's queries to the matching encoder?

level: principalimportance: should knowfreq 30%

basics

~20 s

Route every query by a per-tenant table naming its encoder and vector version, never mixing versions within a query; flip each tenant only after its completeness proof and quality check pass, keep old vectors for rollback, and set a deadline for the tail.

open as a page

How would you set the freshness targets an assistant commits to for an HR handbook, an incident queue and a code repository, and what does each target cost?

level: principalimportance: should knowfreq 32%

basics

~20 s

Set each target from how soon people ask after a change and how harmful a stale answer is, then price it: detection, reserved embedding and churn spend. Give deletes and revocations tighter targets and split each target into per-stage budgets.

open as a page

After a RAG team added overlap and a whole-document summary prefix to every chunk, why does a one-line edit now re-embed whole documents, and how do you fix it?

level: seniorimportance: nice to knowfreq 22%

basics

~20 s

The summary prefix is part of every chunk's embedding input, so any edit that changes the summary changes every fingerprint; overlap only adds a neighbour. Cache or scope the prefix and keep volatile fields out of the input.

open as a page

How do you detect and sweep orphaned chunks in a RAG index, and prove that a full re-run of ingestion changes nothing?

level: seniorimportance: nice to knowfreq 32%

basics

~20 s

Reconcile the store against the document registry: chunks with an unknown document, an inactive generation or an unowned ID are orphans, deleted after a grace period. Prove idempotence by re-running on unchanged sources: zero writes and an unchanged chunk-set digest.

open as a page

As lead of a RAG ingestion pipeline, how do you decide whether to replace fixed-size windows with content-anchored cut points so document edits stay local?

level: principalimportance: nice to knowfreq 20%

basics

~20 s

Measure first: re-embed fraction per edit, edit rate and where edits land. Content-anchored cuts pay off for long, often-edited documents with mid-document inserts; their price is variable chunk sizes, a one-time corpus re-chunk and a fresh retrieval evaluation.

open as a page