Neo4j implementation of GraphStore.
Maps GraphStore operations to Cypher queries via the official Neo4j Java driver. All nodes carry the :LLM4S label for namespace isolation alongside any user-defined label stored as the llm4s_label property.
Connection management: each GraphStore call acquires a single session, executes the query, then closes the session — mirroring the PgVectorStore pattern. The driver (and its internal connection pool) is managed externally; pass ownsDriver = true only when this store should close the driver on close().
Thread-safety: the Neo4j Java driver is thread-safe; this class inherits that.
Value parameters
- database
-
Target database name (default "neo4j")
- driver
-
Neo4j Java driver instance
- ownsDriver
-
Whether to close the driver on
close()(default true)
Attributes
- Companion
- object
- Graph
-
- Supertypes
Members list
Value members
Concrete methods
Closes the driver if this store owns it.
Closes the driver if this store owns it.
Attributes
Deletes a specific edge.
Deletes a specific edge.
Value parameters
- relationship
-
The relationship type
- source
-
The source node ID
- target
-
The target node ID
Attributes
- Returns
-
Right(()) on success or if edge doesn't exist, Left(error) on failure
- Definition Classes
Deletes a node and all its connected edges.
Deletes a node and all its connected edges.
Value parameters
- id
-
The node ID to delete
Attributes
- Returns
-
Right(()) on success or if node doesn't exist, Left(error) on failure
- Definition Classes
Executes an arbitrary read-only Cypher query and returns results as a list of maps (column name → value as String).
Executes an arbitrary read-only Cypher query and returns results as a list of maps (column name → value as String).
Attributes
Executes an arbitrary write Cypher query. Useful for schema migrations and bulk operations outside the GraphStore API.
Executes an arbitrary write Cypher query. Useful for schema migrations and bulk operations outside the GraphStore API.
Attributes
Retrieves neighboring nodes and their connecting edges.
Retrieves neighboring nodes and their connecting edges.
Value parameters
- direction
-
The direction of traversal (Outgoing, Incoming, Both)
- nodeId
-
The ID of the node
Attributes
- Returns
-
Right(Seq of (edge, neighbor node)) on success, Left(error) on failure
- Definition Classes
Retrieves a node by ID.
Retrieves a node by ID.
Value parameters
- id
-
The node ID
Attributes
- Returns
-
Right(Some(node)) if found, Right(None) if not found, Left(error) on failure
- Definition Classes
Loads the entire graph.
Loads the entire graph.
For implementations backed by external databases, consider pagination or size limits to avoid memory issues with large graphs.
Attributes
- Returns
-
Right(graph) on success, Left(error) on failure
- Definition Classes
Queries the graph based on filter criteria. Returns a subgraph matching the filter conditions.
Queries the graph based on filter criteria. Returns a subgraph matching the filter conditions.
If propertyKey or propertyValue filters are specified but not supported, the implementation must either apply them or return a clear error.
Value parameters
- filter
-
The filter criteria
Attributes
- Returns
-
Right(subgraph) on success, Left(error) on failure
- Definition Classes
Computes statistics about the graph.
Computes statistics about the graph.
Attributes
- Returns
-
Right(stats) on success, Left(error) on failure
- Definition Classes
Traverses the graph starting from a node using BFS. All implementations must use Breadth-First Search for consistent result ordering.
Traverses the graph starting from a node using BFS. All implementations must use Breadth-First Search for consistent result ordering.
Missing start node: should return Right(Seq.empty) not an error, since traversal of a non-existent node yields no nodes.
Value parameters
- config
-
Traversal configuration (depth, direction, visited set). The direction parameter controls whether traversal follows outgoing, incoming, or all edges from each node.
- startId
-
The ID of the starting node
Attributes
- Returns
-
Right(Seq of traversed nodes) on success, Left(error) on critical failure
- Definition Classes
Inserts or updates an edge in the graph. Both source and target nodes must exist. If an edge with the same source, target, and relationship already exists, it is replaced.
Inserts or updates an edge in the graph. Both source and target nodes must exist. If an edge with the same source, target, and relationship already exists, it is replaced.
Value parameters
- edge
-
The edge to upsert
Attributes
- Returns
-
Right(()) on success, Left(error) if source or target nodes don't exist
- Definition Classes
Inserts or updates a node in the graph. If the node ID already exists, the existing node is replaced.
Inserts or updates a node in the graph. If the node ID already exists, the existing node is replaced.
Value parameters
- node
-
The node to upsert
Attributes
- Returns
-
Right(()) on success, Left(error) on failure
- Definition Classes