<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/parse-the-folder-not-just-the-pdfs-the-relational-tables-rag-needs-on-a-case-file-gnvll51lj" -->

---
title: Parse the Folder, Not Just the PDFs: The Relational...
description: Case files—bundles of unlike documents about one entity, like an insurance claim folder—behave differently from a single document or a homogeneous corpus, and...
canonical: https://daily.dev/posts/parse-the-folder-not-just-the-pdfs-the-relational-tables-rag-needs-on-a-case-file-gnvll51lj
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Parse the Folder, Not Just the PDFs: The Relational Tables RAG Needs on a Case File | daily.dev
og:description: Case files—bundles of unlike documents about one entity, like an insurance claim folder—behave differently from a single document or a homogeneous corpus, and...
og:url: https://daily.dev/posts/parse-the-folder-not-just-the-pdfs-the-relational-tables-rag-needs-on-a-case-file-gnvll51lj
og:image: https://api.daily.dev/og/posts/GnvlL51lj.png
og:image:alt: Parse the Folder, Not Just the PDFs: The Relational Tables RAG Needs on a Case File
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Parse the Folder, Not Just the PDFs: The Relational Tables RAG Needs on a Case File

**[Towards Data Science](https://daily.dev/sources/tds)** · 23 min read · 0 upvotes · 0 comments

## Summary

Case files—bundles of unlike documents about one entity, like an insurance claim folder—behave differently from a single document or a homogeneous corpus, and RAG systems built for those other shapes fail on them. Two questions typical of case handling, whether an expected document is missing and whether two documents contradict each other, cannot be answered by retrieval because there is no passage to rank. The proposed fix is to parse the folder into two relational tables (expected pieces per case type, and arrived files matched to roles), run a completeness join to detect missing pieces with reasons, declare field pairs to compare across documents with typed values and citations, and return a composed CaseState object (present, missing, unmatched, conflicts, verdict) instead of a ranked passage. Includes Pydantic-style schemas, a worked fire-claim example, and pointers to a companion notebook and the wider 'Enterprise Document Intelligence' series.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://towardsdatascience.com/parse-the-folder-not-just-the-pdfs-the-relational-tables-rag-needs-on-a-case-file>

## Questions this post answers

### Why does top-k retrieval fail to detect a missing document in a RAG pipeline over a folder of case files?

An empty retrieval result carries no information about why it is empty, so a document that was never filed looks identical to one filed under a strange name. The fix is a completeness check: a declared list of expected roles per case type, each with a condition for when it's required, joined against the files actually assigned roles, so absence gets a named reason instead of a silent null result.

_Anyone building document-heavy RAG pipelines can track these architecture patterns via daily.dev._

### How do you detect contradictions between two documents in a RAG system, like mismatched dates on different forms?

Contradictions can't be found by similarity ranking because both conflicting passages read as ordinary on their own and neither mentions the other. Instead, declare which field pairs to compare between which document roles (for example date_of_loss on a claim form versus an adjuster's report), extract each with a typed contract and citation, normalize the values, then compare them directly rather than relying on retrieval.

_Developers designing document comparison logic can follow these RAG design patterns on daily.dev._

### What fields should an expected-piece schema include when checking if a case file folder is complete?

An expected piece needs four fields: role (the business name, like 'loss adjuster report'), min_count and max_count (how many are expected), required_when (a condition on the case's own fields, like cause_of_loss == 'fire'), and blocks_payment (whether the case can proceed without it). This lets a completeness check avoid false alarms on conditions that don't apply and flag which missing pieces actually matter.

_Teams building compliance or intake checks can find similar schema patterns on daily.dev._

## Similar posts on daily.dev

- [Multi-Document RAG: A Folder of Unrelated PDFs Is One Long Document with a Nested Outline](https://daily.dev/posts/multi-document-rag-a-folder-of-unrelated-pdfs-is-one-long-document-with-a-nested-outline-qzfyeax7n) · Towards Data Science · 1 upvotes · 0 comments
- [Three Kinds of RAG Corpus, and What It Costs to Build for the Wrong One](https://daily.dev/posts/three-kinds-of-rag-corpus-and-what-it-costs-to-build-for-the-wrong-one-hvbi0f3zn) · Towards Data Science · 0 upvotes · 0 comments
- [A Production RAG Pipeline for PDFs: Relational Parsing, TOC Retrieval, Typed Answers](https://daily.dev/posts/a-production-rag-pipeline-for-pdfs-relational-parsing-toc-retrieval-typed-answers-vuwase0nh) · Towards Data Science · 1 upvotes · 0 comments
- [I Built a Hybrid RAG Pipeline Over SEC Filings — Here’s What Broke, and Why That Was the Point](https://daily.dev/posts/i-built-a-hybrid-rag-pipeline-over-sec-filings-here-s-what-broke-and-why-that-was-the-point-nuh5kchyt) · Medium · 0 upvotes · 0 comments
- [Multimodal RAG in 2026: Retrieval Over Images, PDFs, and Text](https://daily.dev/posts/multimodal-rag-in-2026-retrieval-over-images-pdfs-and-text-xdl2tl5fu) · BigData Boutique blog · 1 upvotes · 0 comments

---

Tags: [#llm](https://daily.dev/tags/llm), [#rag](https://daily.dev/tags/rag), [#pydantic](https://daily.dev/tags/pydantic)

[View this post on daily.dev](https://daily.dev/posts/parse-the-folder-not-just-the-pdfs-the-relational-tables-rag-needs-on-a-case-file-gnvll51lj)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Parse the Folder, Not Just the PDFs: The Relational Tables RAG Needs on a Case File","url":"https://daily.dev/posts/parse-the-folder-not-just-the-pdfs-the-relational-tables-rag-needs-on-a-case-file-gnvll51lj","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/parse-the-folder-not-just-the-pdfs-the-relational-tables-rag-needs-on-a-case-file-gnvll51lj"},"datePublished":"2026-08-23T15:09:32.169Z","dateModified":"2026-08-23T15:09:57.496Z","description":"Case files—bundles of unlike documents about one entity, like an insurance claim folder—behave differently from a single document or a homogeneous corpus, and...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/e289b81bf0faa2993e4843f78ddcd6c9?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/e289b81bf0faa2993e4843f78ddcd6c9?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Towards Data Science","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Towards Data Science","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/tds","url":"https://daily.dev/sources/tds"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/parse-the-folder-not-just-the-pdfs-the-relational-tables-rag-needs-on-a-case-file-gnvll51lj","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"llm,rag,pydantic","timeRequired":"PT23M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Towards Data Science","item":"https://daily.dev/sources/tds"},{"@type":"ListItem","position":3,"name":"Parse the Folder, Not Just the PDFs: The Relational Tables RAG Needs on a Case File"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/parse-the-folder-not-just-the-pdfs-the-relational-tables-rag-needs-on-a-case-file-gnvll51lj#faq","mainEntity":[{"@type":"Question","name":"Why does top-k retrieval fail to detect a missing document in a RAG pipeline over a folder of case files?","acceptedAnswer":{"@type":"Answer","text":"An empty retrieval result carries no information about why it is empty, so a document that was never filed looks identical to one filed under a strange name. The fix is a completeness check: a declared list of expected roles per case type, each with a condition for when it's required, joined against the files actually assigned roles, so absence gets a named reason instead of a silent null result. Anyone building document-heavy RAG pipelines can track these architecture patterns via daily.dev."}},{"@type":"Question","name":"How do you detect contradictions between two documents in a RAG system, like mismatched dates on different forms?","acceptedAnswer":{"@type":"Answer","text":"Contradictions can't be found by similarity ranking because both conflicting passages read as ordinary on their own and neither mentions the other. Instead, declare which field pairs to compare between which document roles (for example date_of_loss on a claim form versus an adjuster's report), extract each with a typed contract and citation, normalize the values, then compare them directly rather than relying on retrieval. Developers designing document comparison logic can follow these RAG design patterns on daily.dev."}},{"@type":"Question","name":"What fields should an expected-piece schema include when checking if a case file folder is complete?","acceptedAnswer":{"@type":"Answer","text":"An expected piece needs four fields: role (the business name, like 'loss adjuster report'), min_count and max_count (how many are expected), required_when (a condition on the case's own fields, like cause_of_loss == 'fire'), and blocks_payment (whether the case can proceed without it). This lets a completeness check avoid false alarms on conditions that don't apply and flag which missing pieces actually matter. Teams building compliance or intake checks can find similar schema patterns on daily.dev."}}]}
```

