Surreal Cloud Enterprise is now available
Sign up to our Early Access Programme

Build GraphRAG inside your database - without pipelines or glue code

SurrealDB lets you store, enrich, and retrieve a living knowledge graph + vector index in one system. Forget shuffling documents between OLTP data stores, a separate graph DB, and another vector search service. With SurrealDB, GraphRAG is a single query.

Why GraphRAG matters

LLM hallucination

Large language models hallucinate when context is thin, returning results that are little more than educated guesses.

Limited relevance

Classic RAG treats relevance as nearest-neighbour similarity, missing deeper relationships and connected reasoning.

Complex architecture

Conventional stacks force you to stitch together multiple services: relational, document, graph, vector stores, full-text search, ETL jobs, and message queues.

Operational overhead

That complexity kills iteration speed and security reviews, making it hard to maintain and scale.

Graph and vector synergy in one query

SurrealDB lets you store, enrich, and retrieve a living knowledge graph and vector index in one system. Forget shuffling documents between OLTP data stores, a separate graph DB, and another vector search service. With SurrealDB, GraphRAG is a single query.

SELECT sample, content, <-composed_of<-element, ->soluble_with->solid, vector::similarity::cosine(embedding, $lead_harmful) AS dist FROM liquid WHERE embedding <|2|> $lead_harmful;

One SurrealQL round-trip gives you

Vector search

Search embeddings using the <|N|> syntax with HNSW and MTREE indexes for similarity search.

Graph hops

Traverse related tables via graph edges using the -> and <- arrow syntax.

Structured output

Output is immediately ready for the LLM prompt, either in SurrealQL or JSON format.

No complexity

No ETL, no cross-service joins, no consistency gaps - everything in one system.

Key capabilities for GraphRAG

CapabilityInside SurrealDB
Graph + Vector in one engineGraph traversal and vector similarity evaluated together using -> graph and <|N|> syntax
Removes network hops; lowers latency
Dynamic, mutable knowledge graphInsert new facts while using LIVE SELECT to see changes in real time
Agents can write back new facts mid-conversation
Multi-model queryingBlend graph, relational, and document filters
Augment reasoning with prices, counts, time windows
Time-travel consistencyRead consistent, historical data snapshotss
Auditable, repeatable LLM prompts

Generative query example

Many tools such as Rig have been developed for SurrealDB, making getting started with RAG as easy as a few lines of code.

#[tokio::main] async fn main() -> Result<(), Error> { let surreal = Surreal::new::<Mem>(()).await?; surreal.use_ns("ns").use_db("db").await?; let client = openai::Client::from_env(); let model = client.embedding_model(openai::TEXT_EMBEDDING_3_SMALL); let vector_store = SurrealVectorStore::with_defaults(model.clone(), surreal.clone()); let words = vec![ WordDefinition { word: "flurbo".to_string(), definition: "A fictional currency from Rick and Morty.".to_string(), }, WordDefinition { word: "glarb-glarb".to_string(), definition: "A creature from the marshlands of Glibbo.".to_string(), }, WordDefinition { word: "wubba-lubba".to_string(), definition: "A catchphrase popularized by Rick Sanchez.".to_string(), }, WordDefinition { word: "schmeckle".to_string(), definition: "A small unit of currency in some fictional universes.".to_string(), }, WordDefinition { word: "plumbus".to_string(), definition: "A common household device with an unclear purpose.".to_string(), }, WordDefinition { word: "zorp".to_string(), definition: "A term used to describe an alien greeting.".to_string(), }, ]; let documents = EmbeddingsBuilder::new(model) .documents(words) .unwrap() .build() .await?; vector_store.insert_documents(documents).await?; ... }
... let linguist_agent = client .agent(openai::GPT_4_1_NANO) .preamble("You are a linguist. If you don't know don't make up an answer.") .dynamic_context(3, vector_store) .build(); let prompts = vec![ "What is a zorp?", "What's the word that corresponds to a small unit of currency?", "What is a gloubi-boulga?", ]; for prompt in prompts { let response = linguist_agent.prompt(prompt).await?; println!("{}", response); } Ok(())

Operational wins for architects

ConcernSurrealDB answer
Fewer moving partsSingle binary handles OLTP, graph, vector, full-text search, file storage, and data streaming
Predictable spendScale out with horizontal clustering for fault-tolerance and high availability
GovernanceAudit trails simplify regulatory reviews and compliance
Return on InvestmentCut ETL jobs, message brokers, and custom glue code. Iterate faster with a lower Total Cost of Ownership.

Powering innovation across industries

Personalised shopping experiences with AI

Personalised shopping experiences with AI

Saks Fifth Avenue uses SurrealDB to power AI-driven, real-time product recommendations, boosting engagement and conversions in luxury e-commerce.

AI-powered real-time sports analytics

AI-powered real-time sports analytics

GameScript accelerates time-to-market with SurrealDB's multi-model, AI and real-time capabilities.

Learn more

Minimal LangChain chatbot example with vector and graph

featured

Minimal LangChain chatbot example with vector and graph

Jul 4, 2025

Make a GenAI chatbot using GraphRAG with SurrealDB + LangChain

featured

Make a GenAI chatbot using GraphRAG with SurrealDB + LangChain

Jun 30, 2025

Semantic search with SurrealDB and OpenAI

featured

Semantic search with SurrealDB and OpenAI

Jun 26, 2025

Cooking up faster RAG using in-database embeddings in SurrealDB

engineering

Cooking up faster RAG using in-database embeddings in SurrealDB

Apr 2, 2025

Find your celebrity soulmate with the magic of vector search

tutorials

Find your celebrity soulmate with the magic of vector search

Feb 27, 2025

Enhancing Retrieval-Augmented Generation with SurrealDB

tutorials

Enhancing Retrieval-Augmented Generation with SurrealDB

Jan 31, 2025

Moving from Full-Text search to Vector search in SurrealDB

engineering

Moving from Full-Text search to Vector search in SurrealDB

Jul 25, 2024

Ready to build
with GraphRAG?

Start building intelligent applications with graph and vector search in one database.

Start for free
Learn more