Manuscript Offprint

arXiv:2608.21237

Indexing Long Documents for LLM-Based Analysis

Donna Pham

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract.

Long documents such as clinical records, legal contracts, and scientific papers are increasingly analyzed with large language models (LLMs). Naturally, feeding the full document to the model for every question can eventually become slow, expensive, prone to hallucination, and it reuses no work across questions. We explore an indexing-based solution for document analysis and propose a hierarchical plain-text index that is built once per document and consulted by subsequent queries. Inspired by the classic B+ tree, the index organizes a document into pages arranged from general summaries at the root to specific ones at the leaves, but it departs from the B+ tree in three ways suited to LLM access: content lives at every level, the index is plain text rather than attribute values, and navigation follows relevance between page summaries rather than comparing a search key. Its structure is discovered per document by the LLM rather than being hand-designed. In a preliminary evaluation on the NarrativeQA dataset, the index reaches accuracy comparable to DocETL, the strongest baseline, while being 40% cheaper to answer questions.

VLDB Workshop Reference Format: Indexing Long Documents for LLM-Based Analysis. VLDB 2026 Workshop: VLDB Ph.D. Workshop.

1. Introduction

Long-document analysis is an important but expensive task. Clinical records, legal contracts, and scientific papers are routinely examined in depth, and analyzing them by hand is slow and labor-intensive. The expense grows further when the same document must be analyzed many times: a patient record is consulted by clinicians over time, a contract is revisited across many matters, and a scientific paper is queried for many different research questions. A recent and promising line of work uses large language models (LLMs) to do this automatically, answering the free-form questions that previous keyword and extraction tools could not (Shankar et al., 2025a; Patel et al., 2025).

When the LLM is prompted with the full document on each question, the cost of answering grows linearly with the size of the document. Long contexts add a problem of their own: as the input grows, the model fabricates answers more often at a rate that climbs steeply with context length, even when the answer is present in the document (Liu et al., 2024). DocETL (Shankar et al., 2025a), together with related declarative pipelines such as Lotus (Patel et al., 2025) and Palimpzest (Liu et al., 2025), makes the analysis more capable through agentic query rewriting and chunked execution. These systems are stateless: they maintain no state between queries, processing each question from scratch over the original document that result in two consequences follow. First, optimizing a single pass offers only limited acceleration. Second, the full cost recurs on every question, since nothing is amortized across them.

A natural optimization is to precompute some intermediate state once and reuse it across questions. Two families of approaches do this. The first builds a vector index over the document. Retrieval-augmented generation (Lewis et al., 2020) splits the document into chunks and embeds each as a vector; GraphRAG (Edge et al., 2024) and LightRAG (Guo et al., 2025) add graph structure and community summaries on top for questions that span the whole document. The shared limitation is the vector index itself: splitting fragments connections between distant passages and top-kk retrieval surfaces only a few, so whole-document questions return incomplete context; the fixed-dimensional embedding is lossy; and the index is tied to one model, so it must be rebuilt whenever that model changes. The second family extracts chosen attributes into a structured table. Information-extraction systems such as Evaporate (Arora et al., 2023), Doctopus (Chai et al., 2025), and ZenDB (Lin et al., 2024) do this; the result is precise for filter-style lookups, but cannot answer open-ended natural-language questions, and the attributes must be fixed before anyone knows what will be asked.

In this paper, we explore a different path. We return to the successful principles from the database literature, where answering many queries over a large body of data without scanning it is precisely the problem that the index, and in particular the B+ tree (Comer, 1979; Bayer and McCreight, 1972), has solved for decades. We read each document once and compile it into a hierarchical, plain-text index that any LLM can read directly: a few high-level summaries at the root, topic-level summaries beneath them, and detailed page summaries at the leaves. The index is built once per document and consulted by every later analysis, exactly as a database index is built once and reused by every query.

This keeps the reuse benefit shared by vector indices and structured extraction while avoiding the weakness of each. Like a vector index, it is built once and reused, but because it is plain text it is model-independent and preserves the cross-document connections that chunking destroys. Like structured extraction, it imposes organization on the document, but because that organization is discovered by the LLM rather than fixed in a schema, it answers deep, open-ended questions rather than only filter-style lookups. Each node is a short summary sized to fit comfortably within the model’s context window.

Although the index borrows the B+ tree’s shape, hierarchical access over pages, it departs from it in three ways suited to LLM access. Content lives at every level, not only at the leaves, so many questions are answered from an internal summary without descending further, much as a covering index answers a query from the index alone without touching the base table (Graefe, 2011). The index is plain text rather than embedded vectors, so any model can read it and context is preserved by construction. Navigation is semantic: the model judges which summaries are relevant rather than comparing a search key, so the same index serves open-ended analysis rather than only exact-match or range queries.

In this work we explore the design of this new kind of index: how its structure is discovered from a corpus rather than hand-designed, how each document is compiled into it, and how questions are answered against it and the index refined over time.

Section 2 examines the limits of current practice in more detail. Section 3 presents the index and its three design components. Section 4 reports a preliminary evaluation on NarrativeQA, and Section 5 concludes.

References (14)