---
title: "GraphRAG | SurrealDB"
description: "GraphRAG on SurrealDB: graph traversal, vector search and full-text ranking in one SurrealQL query, with no separate vector store."
url: https://surrealdb.com/solutions/graph-rag
---

# GraphRAG, in one engine

Flat vector search returns disconnected chunks. GraphRAG grounds retrieval in the relationships between your entities - and SurrealDB runs the traversal, the vector search, and the ranking in a single query.

[Start free with SurrealDB](https://studio.surrealdb.com/current/instances/deploy) [View documentation](https://surrealdb.com/docs/what-is-surrealdb)

1. ![Babcock](https://surrealdb.com/assets/static/babcock.lo4rnVg1.svg)
2. ![ING](https://surrealdb.com/assets/static/ing.X3I6S3_V.svg)
3. ![British Airways](https://surrealdb.com/assets/static/british-airways.KEsZiwV-.svg)
4. ![Nvidia](https://surrealdb.com/assets/static/nvidia.DaIEuMil.svg)
5. ![Apple](https://surrealdb.com/assets/static/apple.D5pq4flY.svg)
6. ![SpaceX](https://surrealdb.com/assets/static/spacex.CQJEk-IL.svg)
7. ![Samsung](https://surrealdb.com/assets/static/samsung.CH-vQgnb.svg)
8. ![adidas](https://surrealdb.com/assets/static/adidas.DdTC5qhk.svg)
9. ![Tencent](https://surrealdb.com/assets/static/tencent.paQmLxyy.svg)
10. ![Alibaba](https://surrealdb.com/assets/static/alibaba.B16idgfM.svg)
11. ![PolyAI](https://surrealdb.com/assets/static/poly-ai.c3w_fAg6.svg)
12. ![Later](https://surrealdb.com/assets/static/later.Ds736jFO.svg)
13. ![Verizon](https://surrealdb.com/assets/static/verizon.BI7CajdX.svg)
14. ![Liberty Mutual](https://surrealdb.com/assets/static/liberty-mutual.B7qOU1pd.svg)
15. ![Walmart](https://surrealdb.com/assets/static/walmart.BjDg_Sr8.svg)
16. ![Carrier](https://surrealdb.com/assets/static/carrier.D21gC6NX.svg)
17. ![Saks Fifth Avenue](https://surrealdb.com/assets/static/saks-fifth-avenue.COIDpLSb.svg)
18. ![San Francisco Compute Company](https://surrealdb.com/assets/static/sfcc.B7jlImq4.svg)
19. ![Shield AI](https://surrealdb.com/assets/static/shield-ai.pINZ0KJr.svg)
20. ![Wix](https://surrealdb.com/assets/static/wix.DvHhmoBi.svg)

WHY GRAPHRAG

## Retrieval that understands relationships

A vector store can tell you which chunks look similar to a question. It cannot tell you how those chunks relate: which customer raised the ticket, which system the incident touched, which decision superseded which. GraphRAG keeps that structure in the retrieval path, so agents answer from connected context rather than isolated fragments.

### Traverse, don't just match

Typed graph edges are first-class records. Retrieval walks from a matched document to the entities, decisions, and events around it in the same query. No second system, no join gymnastics.

### Hybrid ranking built in

HNSW vector indexes and BM25 full-text search live beside your operational data. Combine semantic similarity, keyword relevance, and reciprocal rank fusion natively in SurrealQL.

### One round trip

No stitching a vector database to a graph database and reconciling results in application code. One engine, one query, one consistent snapshot, and lower latency on every agent turn.

HOW IT WORKS

## Three retrieval modes, one SurrealQL query

Embed the question, recall semantically similar passages, rank them against keyword relevance, then walk the graph from the winners to the entities that ground the answer.

```
-- Embed the question onceLET $q = "why did the deployment fail on Tuesday?";LET $vec = fn::embed($q);-- Hybrid recall: vector similarity fused with BM25LET $passages = search::rrf([    (SELECT id, title,        (1 - vector::distance::knn()) AS vec_score    FROM document    WHERE embedding <|10,40|> $vec),    (SELECT id, title,        search::score(1) AS bm25_score    FROM document    WHERE content @1@ $q    ORDER BY bm25_score DESC)], 10);-- Ground the winners: walk to the entities around themSELECT id, title,    ->mentions->entity.* AS entities,    ->mentions->entity->relates_to->entity.* AS relatedFROM $passages;
```

MANAGED OR HAND-BUILT

## Build GraphRAG yourself, or let agent memory build it for you

Everything on this page is available in the database today: you design the schema, own the graph, and compose the queries. [Agent Memory](https://surrealdb.com/agent-memory), our agent memory layer in early access, runs the same pipeline for you - extracting entities, building the knowledge graph, and serving hybrid retrieval from your conversations, documents, and systems.

FREQUENTLY ASKED QUESTIONS

## GraphRAG

What is GraphRAG?

Why run GraphRAG on SurrealDB rather than two databases?

Do I need Agent Memory to use GraphRAG?

GET STARTED

## Ground your retrieval

Graph traversal, vector search, and full-text ranking in one engine. Start with the database, or join the early access for managed agent memory.

![Samsung](https://surrealdb.com/assets/static/4c58b81e7b3c9466.C_Hv0eml.svg)![NVIDIA](https://surrealdb.com/assets/static/nvidia.DaIEuMil.svg)![Apple](https://surrealdb.com/assets/static/f7dc2519e0d212bc.Cn8MYAK7.svg)![Verizon](https://surrealdb.com/assets/static/18b99996c689000f.B5PQ-nI9.svg)![Tencent](https://surrealdb.com/assets/static/401d8346058682c8.DqM87mst.svg)

SOC 2 Type 2

GDPR

Cyber Essentials Plus

ISO 27001

[Start free with SurrealDB](https://studio.surrealdb.com/current/instances/deploy) [Join agent memory early access](https://surrealdb.com/agent-memory/get-started)

```json
{"@context":"https://schema.org","@type":"Organization","name":"SurrealDB","url":"https://surrealdb.com","logo":"https://surrealdb.com/assets/static/logo.BG7_TG2b.svg","description":"SurrealDB is the unified data layer for AI. A multi-model database for documents, graphs, vectors, and time-series.","foundingDate":"2022","legalName":"SurrealDB Ltd","identifier":{"@type":"PropertyValue","propertyID":"GB-COH","value":"13615201"},"address":{"@type":"PostalAddress","streetAddress":"3rd Floor, 1 Ashley Road","addressLocality":"Altrincham","addressRegion":"Cheshire","postalCode":"WA14 2DT","addressCountry":"GB"},"contactPoint":[{"@type":"ContactPoint","contactType":"customer support","email":"support@surrealdb.com","url":"https://surrealdb.com/contact","availableLanguage":"English"},{"@type":"ContactPoint","contactType":"sales","email":"info@surrealdb.com","url":"https://surrealdb.com/contact","availableLanguage":"English"},{"@type":"ContactPoint","contactType":"security","email":"security@surrealdb.com","url":"https://surrealdb.com/.well-known/security.txt","availableLanguage":"English"},{"@type":"ContactPoint","contactType":"legal","email":"legal@surrealdb.com","url":"https://surrealdb.com/legal","availableLanguage":"English"}],"hasCertification":[{"@type":"Certification","name":"SOC 2 Type 2"},{"@type":"Certification","name":"GDPR"},{"@type":"Certification","name":"Cyber Essentials Plus"},{"@type":"Certification","name":"ISO 27001"}],"owns":[{"@type":"SoftwareApplication","name":"SurrealDB","url":"https://surrealdb.com/surrealdb"},{"@type":"SoftwareApplication","name":"Agent Memory","url":"https://surrealdb.com/agent-memory"}],"knowsAbout":["multi-model databases","document databases","graph databases","vector search","time-series databases","SurrealQL","Agent Memory","real-time databases","embedded databases","context layer","graph ontology","distributed database","knowledge graphs","distributed transaction protocols","highly-scalable databases"],"sameAs":["https://www.wikidata.org/wiki/Q124316308","https://github.com/surrealdb/surrealdb","https://twitter.com/surrealdb","https://www.youtube.com/@surrealdb","https://www.linkedin.com/company/surrealdb","https://discord.gg/surrealdb","https://www.reddit.com/r/surrealdb","https://www.instagram.com/surrealdb","https://medium.com/surrealdb","https://dev.to/surrealdb"]}
```

```json
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://surrealdb.com"},{"@type":"ListItem","position":2,"name":"Solutions","item":"https://surrealdb.com/solutions"},{"@type":"ListItem","position":3,"name":"Graph rag","item":"https://surrealdb.com/solutions/graph-rag"}]}
```

```json
{"@context":"https://schema.org","@type":"FAQPage","mainEntity":[{"@type":"Question","name":"What is GraphRAG?","acceptedAnswer":{"@type":"Answer","text":"GraphRAG is retrieval-augmented generation grounded in a knowledge graph. Instead of returning isolated text chunks by vector similarity alone, retrieval follows the relationships between entities, so the model receives connected context: who did what, when, and how it relates to the question."}},{"@type":"Question","name":"Why run GraphRAG on SurrealDB rather than two databases?","acceptedAnswer":{"@type":"Answer","text":"GraphRAG needs graph traversal, vector search, and full-text ranking on the same data. Running them in one engine removes the synchronisation problem between a vector store and a graph store, keeps results in one consistent snapshot, and cuts a network hop from every retrieval."}},{"@type":"Question","name":"Do I need Agent Memory to use GraphRAG?","acceptedAnswer":{"@type":"Answer","text":"No. GraphRAG is a pattern you can build directly on SurrealDB with SurrealQL, and this page shows the core query shape. Agent Memory is the managed option: it assembles the knowledge graph and serves retrieval for you, and is currently in early access."}}]}
```
