Skip to content

When RAG Retrieval Returns Nothing: A Four-Layer Troubleshooting Decision Tree

The worst RAG failure in production is not a wrong answer. It is no answer at all. A wrong answer at least leaves something to trace; an empty result leaves both the user and the on-call engineer staring at the same screen asking the same question: is the data even there?

On an internal enterprise knowledge base, I consolidated this into a four-branch decision tree. The single guiding rule: an empty result is filtered out at some layer, and each layer can mask the problem in the layer below it, so you must confirm top to bottom instead of jumping ahead to tune parameters. The most common mistake is reaching for the similarity threshold first, lowering it until you finally discover the root cause was in the chunking stage. No threshold rescues content that never made it into the index.

60-Second Triage: Three Commands to Pick the Branch

When someone reports "query X returns nothing," run these three commands in this order:

# 1. Grep the raw document corpus for an exact token from the query (30 seconds, decisive)
grep -rn "the-token-or-error-code" /data/kb/raw/ | head -5

# 2. Confirm the chunk actually exists in the vector store
curl -s "http://localhost:19530" -X POST \
  -H "Content-Type: application/json" \
  -d '{"collection":"kb_chunks","expr":"text like \"%keyword%\"","limit":5}'

# 3. Take a known-relevant chunk and compute its cosine against the query vector
python3 -c "
import requests, numpy as np
qv = requests.post('http://localhost:11434/api/embed',
    json={'model':'bge-m3','input':'the original query'}).json()['embeddings'][0]
# cv = the stored vector of a known-relevant chunk (fetched from the vector store)
print('cos =', np.dot(qv, cv) / (np.linalg.norm(qv)*np.linalg.norm(cv)))
"

Why this order? Cost rises from command to command, and so does the information gained. Grep is plain text matching and answers the most fundamental question first: does the content exist in the raw corpus at all. The vector-store query is one network round trip and answers whether it was ingested. The cosine check calls the embedding service and answers whether the index is current. Putting the cheapest, most branch-cutting check first is basic troubleshooting economics: often the first grep is the entire answer, and the other two never run.

The outputs route you into a branch of the decision tree:

Symptom: RAG retrieval returns empty (topK is 0, or all hits dropped)
|
+- grep raw corpus: token / content NOT found
|  +-- document was never ingested ------------------> data problem: add docs, retrieval layer untouched
|  +-- document present but never parsed (PDF tables / images) -> chunking layer: fix parser, re-ingest
|
+- grep found it, but the matching chunk is missing from the vector store
|  +-- chunker dropped / skipped it (code blocks, tables) -> chunking layer: change split strategy, rebuild
|  +-- chunk exists but never made it into the store (ingestion interrupted) -> index layer: check ingestion log, backfill
|
+- chunk is in the vector store, but step 3 cosine is abnormally low (<0.3)
|  +-- low for ALL queries --------------------------> index layer: embedding upgraded but index not rebuilt
|  +-- low only for specific queries ----------------> chunking layer: query and docs use very different vocabularies
|
+- vector store healthy, cosine healthy, still returns empty
   +-- candidates exist before rerank, all dropped after -> reranker layer: guardrail killed them, relax or swap model
   +-- candidate scores all below threshold ------------> threshold layer: inspect the config, do not blindly lower it

The layers expand below, each with a confirmation command, the typical root cause, and the minimal fix.

Layer 1: Chunking Quality — "The Content Is in the Corpus, but Not in the Chunks"

This layer is the sneakiest, because the data itself is present in the corpus; it was simply lost by the ingestion pipeline. Two common root causes.

First, the parser drops structure. Tables, code blocks, headers and footers in PDFs and Word files depend entirely on parser quality. A scenario I worked through (built from a typical production pattern): operations bulk-imported vendor PDF price sheets, all of them tables. The parser used plain text extraction, and tables vanish entirely during extraction, leaving chunks with only fragments like "Price Sheet" and "Unit: CNY." A user queries a part number: grep on the raw PDF text layer finds it, but the vector store has zero hits, because the table was never chunked.

# Confirm the raw document's text layer actually contains the content
pdftotext /data/kb/raw/quote_2026.pdf - | grep "the-part-number"

# Confirm the chunking artifact contains it
python3 -c "
chunks = load_chunks('kb_chunks')   # read from the ingestion artifact
hit = [c for c in chunks if 'the-part-number' in c['text']]
print(len(hit), 'chunks hit')
"

Second, the splitting strategy drops content. Fixed-length splitting, when it hits an oversized table or code block, often either "skips the whole block" or "truncates it." The first throws content away outright; the second tears a semantic unit in half. The check is simple: join all the chunks back together and diff the key lines against the original document.

# Rebuild check: after joining all chunks, key lines must appear intact
def verify_chunks(doc_text: str, chunks: list[dict]) -> list[str]:
    joined = "\n".join(c["text"] for c in chunks)
    missing = []
    for line in doc_text.splitlines():
        line = line.strip()
        if len(line) > 20 and line not in joined:   # only long lines count as lost
            missing.append(line)
    return missing[:10]   # first 10 lost lines; eyeball whether tables or code were dropped

The fix, ordered by cost: patch the parser first (route tables through a structural extractor rather than plain text), then fix the splitting (keep tables as whole blocks, do not tear rows), and only then re-ingest. Back up the vector store before re-ingesting; I will not say that twice.

Layer 2: The Vector Index — "The Chunks Are There, but the Index Is Stale"

The signature symptom of this layer: every query degrades or returns empty, not just some. That global scope is the key signal — chunking problems usually hit specific documents, index problems hit everything.

The most typical root cause is an embedding upgrade without a full index rebuild. The new model's query vectors and the old model's stored vectors are not in the same space, and cosine similarity collapses across the board:

Before upgrade (same model):   query vs relevant chunk cosine  0.62~0.78
After upgrade (no rebuild):    query vs relevant chunk cosine  0.18~0.31  <- whole-corpus collapse

The confirmation command is step 3 from the triage: take a chunk that was a known hit before the upgrade and compute the new query vector's cosine against it. If it sits well below the historical range (a drop of 0.3 or more), the diagnosis is essentially made.

# Confirm which "batch" of vectors lives in the store: check collection metadata or ingestion timestamps
curl -s "http://localhost:19530" -X POST -H "Content-Type: application/json" \
  -d '{"collection":"kb_chunks","field":"model_version","limit":3}'

The only fix is a full rebuild of the vector index, recomputing every chunk's embedding with the new model. There is no "migration" middle ground — once the vector space changes, there is no conversion formula for the old vectors. Re-embedding 100k chunks takes roughly 20 to 40 minutes on bge-m3; schedule it in a low-traffic window and run a golden-set regression when it finishes.

A secondary cause is an interrupted ingestion: a bulk load that died halfway, leaving the second half of the corpus out of the store. The signature is "new documents are unfindable, old documents work," confirmed by the last timestamp in the ingestion log.

Layer 3: The Similarity Threshold — "It Was Recalled, but the Threshold Kept It Out"

By this layer the data exists and the index is current, so the problem is in score filtering. One thing to pin down first: a threshold blocks garbage; it does not decide "not found." The most common configuration error in production is conflating the two.

# A common two-stage filter in retrieval (the source of many incidents)
def retrieve(query, top_n=50):
    hits = vector_search(query, top_n)              # recall
    hits = [h for h in hits if h.score >= 0.5]      # threshold filter <- first gate
    return hits

A threshold that is too tight shows up like this: candidates are recalled, but their scores all cluster in a "just barely" band like 0.45 to 0.49, and >= 0.5 drops all of them, returning empty. Lowering the threshold genuinely helps here, but how far to lower it should not be a guess. My approach is to look at the score distribution on a golden set:

Golden set of 200 items, cosine score distribution of the correct answers:
0.3~0.4    9 items  (4.5%)     <- marginal relevance
0.4~0.5   34 items (17%)       <- relevant but differently worded
0.5~0.7  131 items (65.5%)     <- the bulk
0.7+      26 items (13%)

If 17% of correct answers fall in 0.4 to 0.5, a threshold of 0.5 means one answerable query in six returns empty. Drop the threshold to 0.4 and let the reranker (next layer) wash out the noise that leaks in. Do not expect a single threshold to both block garbage and preserve recall — it cannot do both.

One more subtle point: for a vague query, the threshold "wrongly convicts" good results. A user asks "the service restarted, what now?" and that broad query scores 0.3 to 0.45 against every chunk. The chunks are not irrelevant; the query simply carries little information. The right handling for that kind of query is rewrite-then-retrieve (expand the context, split into sub-queries), not lowering the threshold to force a match.

Layer 4: The Reranker Guardrail — "The First Three Layers Are Clean; the Last Gate Is the One That Dropped It"

If the first three layers are all clean and the recalled candidate scores are healthy, yet the result is still empty, inspect the final gate: the reranker's discard logic.

# Reranker guardrail (the "last gate" in many RAG systems)
RERANK_KEEP = 0.5      # drop any candidate whose rerank score is below this
RERANK_FALLBACK = 0.35 # if topK all sit below this, go to the "not found" path

def after_rerank(query, candidates):
    scored = reranker.score(query, candidates)
    kept = [s for s in scored if s.score >= RERANK_KEEP]
    if not kept:
        return []            # <- empty! What the user sees is "no results"
    return kept

A reranker killing good candidates and a genuine "nothing recalled" look identical from the user's side. There is one way to tell them apart: log the top-5 scores before and after reranking. If healthy candidates exist before reranking and all fall below 0.5 after, the guardrail is the culprit. Two usual root causes:

  1. The reranker and the embedding are not in the same semantic space. For example, bge-m3 for embeddings but a reranker from a different model family; on mixed Chinese-English queries it scores uniformly low across the board. The check: feed the reranker (query, chunk) pairs from the golden set that you have confirmed relevant. If the scores are uniformly below 0.3, the reranker selection is the problem.
  2. A vague query plus a strict guardrail, working together. A vague query recalls candidates that are not strongly relevant to begin with, so rerank scores cannot climb, and 0.5 drops them all. This is the same problem as the vague-query case in layer 3, except it dies at the last gate.

One scenario I postmortemed (built from a typical production pattern): after an internal tool's knowledge base had been live for a week, users collectively reported "it says not found for everything." All three upstream layers were green. The rerank log finally showed it: every query's rerank top-1 score sat between 0.28 and 0.44. The root cause was that during a reranker swap, the normalization flag moved from normalize=True to normalize=False, changing the score scale without anyone adjusting the guardrail threshold. Whenever a model-side parameter changes, every downstream threshold is invalidated — that line belongs in the change checklist.

Three Failure Postmortems (built from typical production scenarios)

Case 1: PDF tables never reached the index. Operations bulk-imported vendor price sheets (all tables); the plain-text extractor dropped the tables entirely, and every part-number query returned empty. Grep on the raw PDF text layer found the content; the chunks had zero hits — a chunking-layer verdict. Fix: route tables through a structural extractor and keep them as whole blocks; after re-ingesting, that class of query went from zero recall to normal. Lesson: "text extraction" and "structural extraction" are two different things. Before importing, run verify_chunks against at least three sample documents that include a table.

Case 2: Embedding upgraded, index never rebuilt. To improve multilingual coverage, the embedding moved from a general English model to bge-m3, but only the incremental documents were re-ingested; the 120k existing chunks still carried the old model's vectors. The day after launch, nearly every query across the corpus returned empty — new query vectors versus old vectors sat around cosine 0.2. The step-3 command settled it in one shot. Fix: recompute all embeddings and re-ingest, 35 minutes in a low-traffic window. Lesson: treat the embedding model version like a database schema — record it in the collection metadata, and before any upgrade, hard-check "stored version == current model version"; on mismatch, block the release.

Case 3: Reranker normalization changed, guardrail did not. During a reranker swap, the normalize flag moved from True to False, so scores shifted from a 0-to-1 normalized scale to raw logits, landing in 0.2 to 0.4. The guardrail RERANK_KEEP=0.5 was left untouched, so every query was emptied at the final gate — indistinguishable from "the corpus has no data" on the user side. One rerank score log revealed it instantly. Fix: restore normalization, and add "rerank score distribution" to the daily dashboard. Lesson: any model-side change (new model, new normalization, new tokenizer) must trigger a review of every downstream threshold; a change ticket that does not list "which thresholds are affected" does not get approved.

Turn the Triage into Monitoring: Do Not Wait for a User to Report "Empty"

Troubleshooting is reactive. At least three of the four layers above can be made proactive; put them on the dashboard and an "empty for everything" incident stops depending on a user to find it.

For layer 1, monitor ingestion coverage: after every bulk import, run verify_chunks automatically, and alert on — and block — any batch whose lost-line rate exceeds a threshold (say 5%). Tables and code blocks are the most likely to be dropped, so the import sample must include at least one table-bearing document, or the pass rate on a pure-text sample is meaningless. The check is cheap, joining 100k chunks is O(N) and takes seconds, and it slots into the last step of the ingestion pipeline.

For layer 2, monitor embedding version consistency: record the model name and version in the collection metadata, and have the application assert on startup that "stored version == currently loaded model version," refusing to start on mismatch. That single line in the application layer blocks the low-grade, high-damage class of incidents in Case 2.

For layers 3 and 4, monitor the score distribution dashboard: sample 200 real queries (or a golden-set subset) daily and record the p50 and p10 of both the vector-recall score and the rerank score distributions. These distributions shift slowly; if p10 suddenly drops more than 0.2, some layer has broken — a model swap, a guardrail change, or a data-source change — and the decision tree locates which one. A distribution collapse is far more useful than an alert on a single "empty result," because a single empty result may simply mean the corpus lacks the answer, while a collapsed distribution is a systemic fault.

My online alert thresholds: alert when the vector-recall p10 drops more than 15% day-over-day, or when the rerank p50 stays below 0.3 for an hour. These two catch both Case 2 and Case 3 before users notice — the first collapses vector p10 straight below 0.2, the second pulls rerank p50 down to 0.3. An empty result is an outcome metric; the score distribution is a cause metric. Monitoring should watch the latter.

Closing: One Independent Judgment

Walking all four layers, my judgment is: in "returns empty" incidents, data and ingestion problems (layers 1 and 2) are the majority, and threshold and guardrail problems (layers 3 and 4) are the minority. The reason is that the former is "the content is genuinely absent" while the latter is "the content is present but a rule blocked it," and the former happens far more often during the launch phase of a new knowledge base. So a top-down triage order is not a preference; it is a hit-rate question. A 30-second grep that settles the question first saves all the downstream layers from wasted tuning.

One specific tradeoff on thresholds: the similarity threshold (say 0.4) only blocks what is "definitely garbage" and never decides "not found"; the "not found" decision belongs to the reranker's fallback line (say 0.35). Two lines with separate jobs — one for noise, one for confidence. Conflating them is the root cause of "lowering the threshold does not help."


Originality statement: All troubleshooting commands, the decision tree, and the cases in this article are organized by the author from hands-on operation of an in-house enterprise RAG system. Cases are built from typical production scenarios and contain no real company names, IP addresses, or specific timelines.