Short answer: use a stable cursor over versioned document results, with an explicit freshness boundary; reserve snapshots for reproducible financial research.
A financial research dashboard should paginate retrieval by a stable cursor over immutable result identities, while chunk versions and source timestamps decide what is eligible for that page. Start with a freshness budget and a deterministic sort key; add vector similarity only as a ranking signal. This keeps an analyst from seeing duplicates, missing a newly filed report, or reading a citation that changed between clicks.
The compact choice matrix is:
| Strategy | Best fit | Failure mode to test |
|---|---|---|
| Offset pagination over a live ranked list | Small, slowly changing corpora | Inserts shift rows, so pages repeat or skip documents |
Cursor over (score, document_id, chunk_version)
|
Interactive analyst search | Cursor is invalid if the sort key is not deterministic |
| Snapshot ID plus cursor | Audits, exports, and reproducible research | Snapshot expires or consumes storage |
| Time-windowed hybrid retrieval | News-heavy coverage with freshness SLAs | Fresh items can crowd out older but relevant evidence |
My default is the second strategy for the dashboard and the third for saved reports. Keep a snapshot boundary when a user needs to reproduce an answer. The catch is that a snapshot adds lifecycle work; a quick exploratory search that tolerates small changes is better served by a live cursor.
What should a financial research dashboard paginate when chunks keep changing?
Paginate result records, not raw vector rows. A result record represents a source document, its selected chunks, and the version that was indexed. The cursor should contain the complete ordering tuple, a snapshot or freshness boundary, and a schema version. Encode it as opaque base64url JSON so clients cannot construct half-valid cursors by hand.
A useful ordering tuple is (rank_score DESC, document_id ASC, chunk_version DESC). Rank scores can tie after rounding, so document_id and chunk_version provide a total order. If the index returns several chunks from one filing, collapse them after retrieval and before pagination; otherwise one 80-page filing can consume an entire page while another source disappears.
Freshness belongs in eligibility, not in a hidden post-sort tweak. Store source_published_at, source_updated_at, indexed_at, and chunk_version. Define a policy such as: include documents updated within 24 hours in the fast lane, then search the full corpus when the fast lane cannot fill the requested page. Write the policy down. Analysts will notice when “latest” silently means “latest indexed.”
One short rule: a cursor is a promise.
If a source is re-chunked, create a new version and leave the old version addressable inside the snapshot that used it. A live search may choose the new version, but a saved citation must resolve to the old one. Deleting old vectors immediately makes pagination look correct while breaking the audit trail later.
How do retrieval architecture, pagination, and freshness interact in practice?
Use a staged pipeline. First apply authorization and source filters. Next retrieve a candidate set using lexical and vector signals. Then rerank candidates with a deterministic tie-breaker. Finally group chunks by document, attach citation spans, and apply the cursor. This ordering matters: applying the cursor before grouping can split one document across pages, while grouping before ranking can discard a high-signal chunk.
A TypeScript boundary can make the contract explicit without binding the UI to an index vendor:
type SearchRequest = {
query: string;
pageSize: number;
cursor?: string;
freshnessHours: number;
snapshotId?: string;
};
type Evidence = {
documentId: string;
chunkId: string;
chunkVersion: number;
score: number;
sourceUpdatedAt: string;
text: string;
};
type SearchPage = {
items: Evidence[];
nextCursor: string | null;
snapshotId: string;
generatedAt: string;
};
export async function searchPage(req: SearchRequest): Promise<SearchPage> {
const boundary = req.snapshotId
? await loadSnapshot(req.snapshotId)
: await openLiveBoundary();
const candidates = await retrieveCandidates(req.query, boundary, req.freshnessHours);
const ranked = rerankDeterministically(candidates);
const grouped = groupByDocument(ranked);
return paginateWithCursor(grouped, req.cursor, boundary);
}
The function deliberately returns snapshotId even for a live boundary. It gives logs and support tooling a handle to the exact search window. The retrieval implementation can use a relational table, a search engine, or a vector index behind this interface; the pagination contract does not change.
Do not treat a nextCursor as proof that another page exists. Return null only after the backend has looked past the requested slice. A common bug is asking for pageSize rows, receiving exactly that many, and emitting a cursor even when the last row was the final eligible document. Fetch one extra grouped result internally, then trim it.
For an implementation check, replay a fixed corpus of 2,000 filings while inserting updates between page requests. Assert that a snapshot walk has no duplicate (documentId, chunkVersion) pairs and no missing IDs. Run the same replay against a live boundary and record the expected difference: new documents may appear, but a cursor must never reorder already emitted rows. A 409 for an expired snapshot is a contract decision, not a reason to silently restart at page one.
Where does this design stop being a good fit?
Cursor pagination is a poor fit for random page jumps. If users demand “go to page 37,” maintain a separate export or materialized result set and expose offsets only inside that frozen artifact. Offset pagination is also acceptable for a static corpus, such as a quarterly archive that never changes after publication.
A freshness-first lane can be wrong for litigation research, where an older filing is the key evidence. In that case, stick with a full-corpus snapshot and show the age of every source. Conversely, a market-news dashboard may accept lower recall for stale documents to keep the first page current. Your mileage may vary; the right threshold comes from analyst interviews and replay data, not a universal 24-hour number.
There is another trade-off: grouping by document improves reading flow but can hide independent evidence chunks. Offer an “expand evidence” action inside a result rather than inflating the top-level page. If users need chunk-level paging for bulk labeling, expose a different endpoint and cursor schema. One cursor serving both workflows becomes configuration bloat.
A small test plan that catches expensive pagination bugs
Measure these invariants in CI and in production sampling:
- The sort tuple is total and stable for every returned item.
- A cursor decodes only under its recorded schema version and snapshot boundary.
- A snapshot walk returns each document version at most once.
- Every citation stores the chunk version and source timestamp used for generation.
- Freshness filtering is visible in response metadata, including the boundary time and policy.
- Repeating a request with the same cursor is idempotent.
Track p95 retrieval latency, candidate-to-result reduction, stale-source rate, and cursor-expiry rate. Also track page-depth abandonment. A dashboard that returns page one in 300 ms but makes page two unusable has a retrieval problem, not a pagination success.
The RAG paper that introduced retrieval-augmented generation describes combining a parametric generator with a non-parametric memory; pagination is the operational detail that determines which part of that memory an analyst actually sees. Treat it as part of the evidence contract.
References
- Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks: https://arxiv.org/abs/2005.11401
- RFC 4648, Base64 Data Encodings: https://www.rfc-editor.org/rfc/rfc4648
- HTTP Semantics (status codes and conditional requests): https://www.rfc-editor.org/rfc/rfc9110
- MDN, Cursor-based pagination discussion: https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams
Top comments (0)