The Big Picture
- Lexical layer — Document and Chunk nodes with provenance edges (the text you ingested, and one chunk per row of every table)
- Knowledge layer — Entity nodes with relationship edges (the knowledge extracted from text, and the entities a table’s rows declare)
MENTIONED_IN edges, which link entities to the chunks where they were found. A table is stored in exactly the same shapes as a document — see Structured Ingestion — so both halves are queried the same way.
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.
Record chunks
A table’s rows are chunks too, one per row, under the table’s Document:
Record chunks are not chained with
NEXT_CHUNK (rows have no reading order) and are not embedded.
Entity Nodes (Person, Organization, etc.)
Purpose: Knowledge entities, extracted from prose or written from a table’s rows. Each entity node has at least two labels: its domain type (e.g.,Person) and __Entity__ (a secondary label shared by all entities). A judged cross-label merge also gives the survivor the labels it absorbed (recorded in merged_labels); an ontology-adoption merge does not.
Created in: Step 7 (Write).
__Entity__ label is automatically added. Embedding is written during finalize().
An entity stays the same size however often it is mentioned. Which chunks mention it, where, and what each says it is are on its MENTIONED_IN edges, one per chunk; the node holds no chunk list. Its descriptions are bounded twice: a write adds at most up to 20 on the node (past that, a mention’s description is kept on its edge only; a write never cuts what a node already holds), and finalize(), after dedup, tries to replace the descriptions of every entity holding more than 5 with one LLM summary of them, marked description_summarised. A summary that fails leaves them as they are, listed in FinalizeResult.description_summary_failures, and the next finalize() tries again.
What a deleted or updated document said is taken off. Before delete_document() or update() removes a document’s chunks, it records what their mention edges said, with the rest of its crash-safe cleanup state; the cleanup then drops exactly that text from the entities’ descriptions, keeping anything a remaining chunk still says, and fills the places this frees on a full node (20) from what the remaining chunks say. No LLM call. If something else writes an entity’s description meanwhile, the entity is read again; one that keeps changing is logged and left, since the delete or update has already taken effect. A summarised entity cannot have text taken out of its summary: when the removed text is no longer said by any remaining edge and every remaining edge records what its chunk said (has said_version; a table row’s edge, which never says anything, does not count), it is rebuilt from them (and summarised again by the next finalize()); otherwise its summary is kept, and the removed text beside it is still dropped.
Graphs written by an earlier version keep their entities’ source_chunk_ids lists and descriptions. MENTIONED_IN edges are what the SDK reads for provenance; the update and delete paths still trim the old lists. Their mention edges carry no said_version — and keep none when a later write adds a description to one — so text a document ingested by an earlier version wrote cannot be taken off on its delete: it is kept, as before this version, and a summarised entity with such an edge is never rebuilt from its edges.
A description stored by an earlier version has no description_piece_count, so it is read as it was written: with the old descriptions list, each list item is one piece; without one, the whole string is one piece, | and all (a table row’s evidence stays whole). The next write of that description stores it with a count and drops the list. A description you write straight to the graph is read as one piece too; one written over a description that has a count must also remove description_piece_count, or it is split at |.
Default entity types (11): Person, Organization, Technology, Product, Location, Date, Event, Concept, Law, Dataset, Method
Entities the NER model scored just below its confidence threshold carry the special label Unknown until the step-2 LLM re-types or drops them; one it kept without a type stays Unknown. Document and Chunk are reserved and cannot be entity labels.
SDK system nodes
Besides your data, the graph holds a small, fixed set of the SDK’s own nodes under two labels:__GraphRAGConfig__ (the embedding model and vector size the graph was written with) and __GraphRAGProcessing__ (dedup work in progress — the run lock, the entities whose dedup check is owed, and an interrupted run’s merge plan; a finished run leaves only what is still owed). They have no edges and no vector, so no traversal or search reaches them, and get_statistics() does not count them. No dedup marker or bookkeeping is written on your entities — only their name vectors, and what a merge folds into the survivor. See Storage.
Edge Types
PART_OF (Document -> Chunk)
Purpose: Provenance — tracks which document a chunk came from. A table’s record chunks hang off its Document the same way.NEXT_CHUNK (Chunk -> Chunk)
Purpose: Sequential ordering — preserves the reading order of chunks within a document. Used to fetch neighboring chunks for context expansion. Prose only: a table’s record chunks are never chained. No additional properties.MENTIONED_IN (Entity -> Chunk)
Purpose: Co-occurrence — links entities to the chunks where they were extracted, and a table row’s entity to its record chunk. This is a critical edge for retrieval: when you find an entity, you can traverse to its source chunks.
Deduplicated by
(entity_id, chunk_id). Written once and deleted with its chunk, so what a deleted document said can be taken off its entities’ descriptions.
RELATES (Entity -> Entity)
Purpose: All relationships between entities, whether extracted from prose or declared by a table’sLink. This is the only relationship type used for extracted and table knowledge edges. The one exception is backfill_relation_pattern() (see Ontology Evolution): it writes edges typed with the relation label itself (for example [:WORKS_AT]), with a description but no fact, embedding or source_chunk_ids, so RELATES vector search and relationship expansion do not see them.
Edge identity includes
rel_type: two facts of different types between the same two entities are two edges, and a dedup merge keeps both.
Why a Single RELATES Edge Type?
You might expect separate edge types likeWORKS_AT, LOCATED_IN, and MARRIED_TO. Instead, extracted and table relationships use the single RELATES type with the original type stored in the rel_type property. Here’s why:
-
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
RELATEStype means one vector index that covers all relationships. - 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.
-
No information loss. The original type is preserved in
rel_typeand appears in thefactstring, so you can still filter by type in custom Cypher queries:
Indexes
The SDK creates 5 standard indexes duringfinalize() (or ensure_indices()). All are idempotent — safe to create repeatedly.
Vector Indexes (3)
Syntax:
Fulltext Indexes (2)
Syntax:
__Entity__ statements build a single index over name and description. They are separate statements so that an existing index on one field cannot stop the other from being added.
ensure_indices() waits until FalkorDB reports every index built (waiting until at most 10 minutes after the call starts, logging progress every 10 seconds; the index-creation statements themselves are not cut off). If the status query fails or the deadline passes, it returns anyway, and a search may run against a half-built index until the build finishes.
Range Indexes on the Write Path
Every write is aMERGE on id, and a MERGE can only use an index on the label in its own pattern. So before writing, the ingestion paths create range indexes:
Without them, writing n nodes cost O(n²). Existing indexes are read once per store (
GraphStore instance; delete_all() makes it read them again) and only the missing ones are created.
The Provenance Chain
The graph structure ensures complete traceability from any answer back to its source:Defining Your Own Ontology
AnOntology tells the extraction pipeline which entity and relationship types to look for, and the pruning step uses it to filter non-conforming data. Pass it as GraphRAG(ontology=...); it is persisted in a paired <graph_name>__ontology graph.
GraphSchema, EntityType, RelationType and PropertyType are deprecated
aliases of Ontology, Entity, Relation and Attribute, and the schema=
keyword is a deprecated alias of ontology=. They still work and emit a
DeprecationWarning.Basic Ontology
Ontology with Patterns
Patterns define which source-target pairs are valid for each relationship type. They are specified directly onRelation:
patterns list is allowed between any entity types.
Typed Attributes
Attribute(name=..., type=..., description=...) (keyword arguments only; it is a pydantic model) declares a typed property on an entity or relation (STRING, INTEGER, FLOAT, BOOLEAN, DATE, LIST). The extractor asks the LLM for declared attributes and coerces each value to its type:
name, description, source_chunk_ids, spans, id, and on edges rel_type, fact, src_name, tgt_name). An attribute a table declared is marked Attribute(structured=True) and carries the table’s signature in its name (employees__age); it is never asked of the LLM.
Tables in the Ontology
Ontology(tables=[TableMapping(...)]) declares how a CSV or other tabular source becomes entities and edges, and Ontology(relationship_tables=[RelationshipMapping(...)]) a table whose rows only connect existing entities. A mapping’s labels, typed columns and links are registered in the ontology before any document is extracted. See Structured Ingestion.
Open Ontology Mode
When the working ontology declares neither entities nor relations, the pipeline operates in open 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, and the 31
DEFAULT_RELATION_TYPESare offered as preferred (not enforced) relation labels
GraphRAG created with no ontology on an empty graph seeds the 11 default entity types into its stored ontology, so entities outside those labels (other than Unknown) are pruned, while relations stay open.
This is good for exploration. For production, a defined ontology produces cleaner, more consistent graphs.
Inspecting the Graph
Statistics
Raw Cypher Queries
rag.query(cypher, params) runs Cypher against your graph and returns the rows as lists. It runs exactly what you pass, so use params for values rather than formatting them into the string: