Skip to content
← All patterns

ai

RAG Chunk Store

Which passages answer this question?

Find one chunk by meaning, then read its neighbours by key.

Retrieval wants small chunks, because a small chunk embeds precisely and a large one blurs into an average of everything it contains. It also wants enough surrounding text for the answer to make sense. Chunk small so the search is sharp, then use the keys you got back to read either side. The search never carries that text and never pays for it.

The model

Chunk

One passage of one document, with the vector of its text.

pk
DOC#<docId>
sk
CHUNK#<seq>

Attributes: corpus (S), text (S), embedding (L)

Access patterns

  • SearchVectors · by-corpusFind the passage

    The chunk nearest the question, across the whole corpus.

  • QueryRead around the hit

    The chunks either side of the winner, for context the search never carried.

Design notes

Two cheap reads beat one fat onecost

Search results are capped at TopK but not capped in size, and vector work is billed by bytes. Returning a full chunk body for every hit means paying for text you mostly discard on every query. Project the keys, then fetch the handful of bodies you actually need.

Zero-padded sequence numbersmodelling

CHUNK#0002 rather than CHUNK#2, so a BETWEEN over the sort key means what it looks like it means. Unpadded, CHUNK#10 sorts before CHUNK#2 and the expand step silently returns the wrong passages.

Taught in the course

rag-chunk-storeDynamoDB workbench
Ready to run
Explore an access patternSelect to load & run

The chunk nearest the question, across the whole corpus.

Request
Execute against the local Dynoxide engine
ReturnedFiltered outChanged
PK(pk)
SK(sk)
corpus
embedding
text
DOC#authentication
CHUNK#0001S
api-docsS
[0.88, 0.14, 0.06, 0.03]L
API keys authenticate a machine, not a personS
DOC#authentication
CHUNK#0002S
api-docsS
[0.84, 0.21, 0.08, 0.04]L
Create a key from project settings and copy it immediatelyS
DOC#authentication
CHUNK#0003S
api-docsS
[0.91, 0.11, 0.05, 0.02]L
To rotate a key, create the replacement first, then revoke the old oneS
DOC#authentication
CHUNK#0004S
api-docsS
[0.86, 0.18, 0.07, 0.05]L
Revoking a key takes effect within seconds across every regionS
DOC#rate-limits
CHUNK#0001S
api-docsS
[0.12, 0.93, 0.09, 0.04]L
Every endpoint is rate limited per project rather than per keyS
DOC#webhooks
CHUNK#0001S
api-docsS
[0.07, 0.10, 0.94, 0.06]L
Webhooks deliver at least once, so your handler must be idempotentS
Awaiting request
Your next query starts here.

Choose an access pattern above, or build your own request. See what comes back and what it costs.

Write transactions, streams, tags and TTL are among the operations this browser build leaves out. dynoxide's native build has them.