The Big Picture
- Lexical layer — Document and Chunk nodes with provenance edges (the text you ingested)
- Knowledge layer — Entity nodes with relationship edges (the structured knowledge extracted from that text)
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 likeWORKS_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:
-
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:
The Provenance Chain
The graph structure ensures complete traceability from any answer back to its source:Defining Your Own Schema
AGraphSchema 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 onRelationType:
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