<!-- generated by build_articles.py — edit content/answers/rag-without-vector-database.md instead -->
---
title: "RAG without a vector database (2026): vectorless RAG with BM25, 3 ways"
canonical: "https://xerj.org/answers/rag-without-vector-database"
updated: "2026-11-15"
source: "content/answers/rag-without-vector-database.md"
---

# RAG without a vector database: 3 vectorless RAG setups that work

**Short answer** (updated 2026-11-15): How do I build RAG without a vector database? Retrieve with BM25 keyword search, the document's own structure, or one search engine that stores vectors beside the text. On BEIR SciFact, XERJ hybrid search scored nDCG@10 0.6993, above BM25 alone (0.6572) and vectors alone (0.6764), from one index.

**Key number:** On BEIR SciFact, hybrid RRF with the opt-in neural embedder scored nDCG@10 0.6993, above both BM25 (0.6572) and vectors alone (0.6764). (as of 2026-09-18; source: [benchmarks/beir-hybrid/results/scifact.txt](https://github.com/xerj-org/xerj/blob/main/benchmarks/beir-hybrid/results/scifact.txt))

**TL;DR** Yes, you can build RAG without a vector database, often called vectorless RAG. RAG needs a retriever, and three kinds work well without one: BM25 keyword search (SQLite FTS5 or a search engine), the document's own structure, or one search engine that keeps vectors beside the text. On BEIR SciFact, XERJ hybrid search scored nDCG@10 0.6993, above BM25 alone (0.6572) and vectors alone (0.6764), all from one index.

## Agent prompt

```text
Act as a coding agent. Read https://xerj.org/llms.txt, start one single-node XERJ, create an index with a semantic_text field, bulk-load the corpus, then run one hybrid request with fusion rrf and report the returned ids and scores before you write any retrieval code.
```

## Commands

### Command 1

Note: Install the single XERJ binary.

```sh
curl -fsSL https://xerj.org/get | sh
```

### Command 2

Note: One index holds the text and its vector. XERJ adds a companion text_vector field for you.

```sh
curl -s -XPUT 'http://127.0.0.1:9200/docs' -H 'content-type: application/json' -d '{"mappings":{"properties":{"title":{"type":"text"},"text":{"type":"semantic_text"}}}}'
```

### Command 3

Note: Keyword (BM25) retrieval on the same index, with no vectors involved.

```sh
curl -s -XPOST 'http://127.0.0.1:9200/docs/_search' -H 'content-type: application/json' -d '{"query":{"match":{"text":"how does the index recover after a restart"}},"size":3}'
```

*Figure: The FTS5 query uses SQLite's built-in bm25() function (sqlite.org/fts5.html, checked 2026-11-14). The hybrid request is the XERJ shape shown in the article; the empty array is where the query vector goes.*

## What RAG actually needs

Retrieval augmented generation has two steps. A retriever finds a few passages that answer the question, and the model writes its answer from those passages. The retriever is the only part that touches your data, and nothing says it has to be a vector store.

Vector databases became the default because embeddings match meaning, so a question phrased in new words still finds the right passage. Keyword search matches exact terms, which is what you want for names, product codes, error strings and identifiers. In the SciFact run below, keyword search alone came close to hybrid search, so it makes a fair first step, and adding vectors later is a tuning step rather than a rebuild.

## Route 1: keyword search with BM25

[BM25](/science/bm25) ranks passages by how often the query words appear in them, weighted so rare words count more than common ones. SQLite ships it: an FTS5 table plus the built-in `bm25()` function is a full retriever in one file.

```sql
CREATE VIRTUAL TABLE chunks USING fts5(source UNINDEXED, body);
SELECT source, body FROM chunks
WHERE chunks MATCH 'restart OR recover'
ORDER BY bm25(chunks) LIMIT 3;
```

Split documents into short chunks, store each with its source path, and pass the top three to the model with an instruction to answer only from them. A search engine such as XERJ does the same over folders of files, logs or code without any schema work. For a full local setup, see [local RAG](/answers/local-rag).

## Route 2: use the document's structure

Manuals, policies and reports already carry an index: their headings and table of contents. Vectorless RAG tools give the model that outline, let it pick the sections that look relevant, then read those sections in full. This suits long, well-structured documents, and it costs more model calls per question than a single search.

## Route 3: one search engine with vectors inside

When paraphrased questions matter, you can still skip the separate vector database. XERJ stores the text and its embedding in the same index. A `semantic_text` field gets a companion `<field>_vector` at write time, and one `hybrid` request fuses a BM25 sub-query and a kNN sub-query with [Reciprocal Rank Fusion](/science/reciprocal-rank-fusion).

```json
{"query":{"hybrid":{"queries":[
  {"query":{"match":{"text":"how does the index recover after a restart"}},"weight":1.0},
  {"query":{"knn":{"field":"text_vector","k":3,"num_candidates":50,"query_vector":[]}},"weight":1.0}],
  "fusion":"rrf"}},"size":3}
```

The empty array marks where the query vector goes. XERJ takes a literal float array, so index the query text into a `semantic_text` field and read its companion vector back from `_source`. The default embedder is lexical feature hashing; start the node with `--embed-mode neural` for a MiniLM-class model.

*Figure: From benchmarks/beir-hybrid/results/scifact.txt in the XERJ repository: xerj v1.0.0-rc.74 with --embed-mode neural (all-MiniLM-L6-v2), one node, run on 2026-09-18. Bars start at 0 and the full width is 1.0. The measured nDCG page has the NFCorpus run and the method.*

On SciFact, 300 queries, all three modes ran on one node. BM25 alone scored 0.0421 below hybrid, which is why keyword search is a strong first step. Hybrid search added the last gain without a second service. More on the method is in [hybrid search](/science/hybrid-search).

## Which route to pick

Start with BM25 when your questions use the same words as your documents, which is common for code, logs, tickets and internal docs. Pick structure-based retrieval for a handful of long, well-organized documents. Add vectors in the same index when users ask in their own words and you have measured that keyword search misses them. If your agent already runs grep, see [when grep is the right retriever](/answers/rag-vs-grep).

## Try it

Copy the prompt on this page into your coding agent. It starts one XERJ node, loads your corpus, runs one hybrid request and reports the ids and scores, so you can compare keyword, vector and fused results on your own data before writing any retrieval code.

More comparisons: [RAGFlow alternatives 2026](/compare/ragflow-alternatives-2026).

## FAQ

### Can you do RAG without a vector database?

Yes. RAG needs a retriever, not a vector database. BM25 keyword search, document structure, or a search engine that stores vectors beside the text all work as the retrieval step.

### Is RAG without embeddings good enough?

Often, yes. On BEIR SciFact our BM25 run scored nDCG@10 0.6572 against 0.6764 for vectors alone. Exact names, codes and error strings are where keyword search shines.

### What is vectorless RAG?

RAG where retrieval uses keyword search or the document's own structure, such as headings and a table of contents, instead of embeddings in a vector store.

### When do vectors help?

When users phrase questions differently from the source text. Hybrid search runs BM25 and vectors together and fuses them, and on SciFact that scored 0.6993.

### Does XERJ need a separate vector database?

No. XERJ stores the dense vector beside the inverted index in one index, and one _search request queries both.

### Is the default XERJ embedder semantic?

The default is lexical feature hashing with no model download. Run the node with --embed-mode neural to use a MiniLM-class embedder.

## Evidence

- SQLite FTS5 ships a built-in bm25() auxiliary function for ranking full-text matches. Source: [https://www.sqlite.org/fts5.html](https://www.sqlite.org/fts5.html)
- BEIR SciFact, xerj v1.0.0-rc.74, --embed-mode neural: BM25 nDCG@10 0.6572, MiniLM vector only 0.6764, hybrid RRF 0.6993. Source: `benchmarks/beir-hybrid/results/scifact.txt`

## Related

- [BM25 vs vector search](/science/bm25)
- [What is hybrid search?](/science/hybrid-search)
- [Reciprocal rank fusion formula](/science/reciprocal-rank-fusion)
- [Local RAG: answer questions over your own files, on your machine](/answers/local-rag)
- [RAG vs grep for AI coding agents](/answers/rag-vs-grep)
- [What is Reciprocal Rank Fusion?](/answers/reciprocal-rank-fusion-when-to-use)
- [What's the actual difference between a vector database and full-text search when I have a folder?](/answers/vector-database-vs-full-text-search)
- [Should my agent call a search API or stand up Qdrant for persistent memory?](/compare/xerj-vs-vector-database)
- [Hybrid search](/docs/recipes/hybrid-search)
- [Agentic RAG vs RAG: which one fits your question?](/answers/agentic-rag-vs-rag)
- [Should an agent use API search or vector search?](/answers/mcp-api-search-or-vector-search) (same intent: retrieval research and eval)
- [When should I turn on neural embeddings, and when is the lexical default enough?](/answers/do-search-embeddings-help) (same intent: retrieval research and eval)
- [How much better is hybrid search than BM25? Measured nDCG numbers](/answers/hybrid-search-quality-measured-ndcg) (same intent: retrieval research and eval)
