Skip to main content
When you ingest documents into GraphRAG SDK, the system builds a property graph in FalkorDB. This document explains exactly what that graph looks like — what node types exist, what edges connect them, what properties they carry, and what indexes make it searchable. Understanding the graph structure helps you write custom Cypher queries, debug ingestion quality, and tune retrieval. Looking to change an existing ontology — add/drop attributes, rename labels, retype fields? See Ontology Evolution for the atomic-evolve API and the alignment invariant it enforces.

The Big Picture

The graph has two layers:
  1. Lexical layer — Document and Chunk nodes with provenance edges (the text you ingested)
  2. Knowledge layer — Entity nodes with relationship edges (the structured knowledge extracted from that text)
The layers are connected by MENTIONED_IN edges, which link entities to the chunks where they were found.

Node Labels

Document

Purpose: Represents a source document that was ingested. Created in: Step 3 (Lexical Graph) of the ingestion pipeline.

Chunk

Purpose: A text fragment from a document. Chunks are the atomic unit of retrieval — when the system finds relevant information, it returns chunks. Created in: Step 3 (Lexical Graph). Embedding added in Step 9.

Entity Nodes (Person, Organization, etc.)

Purpose: Extracted knowledge entities. Each entity node has two labels: its domain type (e.g., Person) and __Entity__ (a secondary label shared by all extracted entities). Created in: Step 7 (Write). __Entity__ label is automatically added. Embedding is backfilled during finalize(). Default entity types (11): Person, Organization, Technology, Product, Location, Date, Event, Concept, Law, Dataset, Method Entities below the NER confidence threshold get the special label Unknown.

Edge Types

PART_OF (Document -> Chunk)

Purpose: Provenance — tracks which document a chunk came from.

NEXT_CHUNK (Chunk -> Chunk)

Purpose: Sequential ordering — preserves the reading order of chunks within a document. Used to fetch neighboring chunks for context expansion. No additional properties.

MENTIONED_IN (Entity -> Chunk)

Purpose: Co-occurrence — links entities to the chunks where they were extracted. This is a critical edge for retrieval: when you find an entity, you can traverse to its source chunks. No additional properties. Deduplicated by (entity_id, chunk_id).

RELATES (Entity -> Entity)

Purpose: All extracted relationships between entities. This is the only relationship type used for knowledge edges.

Why a Single RELATES Edge Type?

You might expect separate edge types like WORKS_AT, LOCATED_IN, and MARRIED_TO. Instead, all relationships use the single RELATES type with the original type stored in the rel_type property. Here’s why:
  1. Index efficiency. Each edge type in FalkorDB needs its own vector index. With potentially hundreds of LLM-generated relationship types, you’d need hundreds of indexes. One RELATES type means one vector index that covers all relationships.
  2. Consistent retrieval. The retrieval system searches all relationships at once via the RELATES edge vector index. Having a single type means one query covers everything.
  3. No information loss. The original type is preserved in rel_type and appears in the fact string, so you can still filter by type in custom Cypher queries:

Indexes

The SDK creates 5 standard indexes during finalize() (or ensure_indices()). All are idempotent — safe to create repeatedly.

Vector Indexes (3)

Syntax:

Fulltext Indexes (2)

Syntax:

The Provenance Chain

The graph structure ensures complete traceability from any answer back to its source:
This is the Zero-Loss Data principle: every piece of source material is traceable in the graph. When the retrieval system provides context to the LLM, it can always point back to which document and which chunk the information came from.

Defining Your Own Schema

A GraphSchema tells the extraction pipeline which entity and relationship types to look for, and the pruning step uses it to filter non-conforming data.

Basic Schema

Schema with Patterns

Patterns define which source-target pairs are valid for each relationship type. They are specified directly on RelationType:
A relationship with an empty patterns list is allowed between any entity types.

Open Schema Mode

If you create an empty schema (GraphSchema()), the pipeline operates in open schema mode:
  • The LLM extracts any entities and relationships it finds
  • The pruning step is skipped entirely
  • The 11 default entity types are used for NER
This is good for exploration. For production, a defined schema produces cleaner, more consistent graphs.

Inspecting the Graph

Statistics

Raw Cypher Queries


File Reference