RAG with RedDB vector search
Insert example vectors into RedDB and retrieve similar content, then build the rest of a retrieval workflow in your application.
On this page
Start with retrieval
A retrieval-augmented generation workflow selects source material and gives it to a model as context. It has several distinct steps: prepare content, create embeddings, retrieve candidates, apply access checks and filters, then generate and evaluate an answer. This article demonstrates the RedDB vector-search step; it does not call an embedding or generation provider.
Try the examples locally
Start RedDB with its HTTP endpoint bound to your local machine:
red server --http-bind 127.0.0.1:5000 --path ./example.rdb --dev--dev disables authentication and is only for a trusted local environment. In a second terminal, define a helper to send a query. It requires curl and jq:
query() {
curl -fsS http://127.0.0.1:5000/query \
-H 'content-type: application/json' \
--data "$(jq -cn --arg query "$1" '{query: $query}')"
}The examples below were executed against RedDB 1.26.8. Use a fresh database for this walkthrough; reusing names from another example can change the results.
Insert and search example vectors
query "INSERT INTO knowledge_chunks VECTOR (dense, content) VALUES ([1.0, 0.0], 'Gateway runbook')"
query "INSERT INTO knowledge_chunks VECTOR (dense, content) VALUES ([0.0, 1.0], 'Database manual')"
query 'VECTOR SEARCH knowledge_chunks SIMILAR TO [1.0, 0.0] LIMIT 2'The tested response returns both items with similarity information, with the gateway runbook ranked first for this query. Two-dimensional vectors make the example easy to inspect; they are not real text embeddings.
Connect this to your content
Your application needs to chunk source content, generate embeddings using a selected model, and use compatible dimensions and preprocessing for stored and query vectors. Maintain source identifiers and permissions in a tested application design. Do not expose retrieved content to a user who is not authorized to see it.
A shared database may simplify parts of a multi-store design, but it does not automatically remove every stale-data or synchronization failure. Define how a source edit reaches the vector used for retrieval, what happens if embedding generation fails, and how you detect and repair missed updates. Test those paths and any atomicity assumptions with your actual model and deployment.
Measure quality and cost
Build an evaluation set with expected sources, test retrieval quality and answer grounding separately, and measure the latency and cost of embedding, retrieval and generation. The vector quickstart and vector reference cover the native model. Provider configuration, answer generation and citations are outside the tested commands above.
Ready to build with RedDB?
Create an account and explore the Always Free database.
Create your account →