or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

configuration.mddatabase-management.mdevents.mdgraph-database.mdgraph-model.mdindex.mdprocedures.mdquery-execution.mdschema.mdspatial.mdtraversal.md
tile.json

tessl/maven-org-neo4j--neo4j

Neo4j Community Edition - The world's leading Graph Database with Cypher query language and ACID transactions.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/org.neo4j/neo4j@5.26.x

To install, run

npx @tessl/cli install tessl/maven-org-neo4j--neo4j@5.26.0

index.mddocs/

Neo4j Community Edition

Neo4j Community Edition is the world's leading Graph Database, providing high-performance graph storage and processing capabilities with the Cypher query language and ACID transactions. It implements the property graph model with nodes and relationships, offering significant performance advantages over traditional relational databases for connected data scenarios.

Package Information

  • Package Name: neo4j
  • Package Type: maven
  • Language: Java
  • Installation:
    <dependency>
      <groupId>org.neo4j</groupId>
      <artifactId>neo4j</artifactId>
      <version>5.26.5</version>
    </dependency>

Core Imports

import org.neo4j.dbms.api.DatabaseManagementService;
import org.neo4j.dbms.api.DatabaseManagementServiceBuilder;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Transaction;

Basic Usage

import org.neo4j.dbms.api.DatabaseManagementService;
import org.neo4j.dbms.api.DatabaseManagementServiceBuilder;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.Label;
import org.neo4j.graphdb.RelationshipType;
import static org.neo4j.graphdb.Label.label;
import static org.neo4j.graphdb.RelationshipType.withName;

// Create database management service
DatabaseManagementService managementService = new DatabaseManagementServiceBuilder(databaseDirectory)
    .build();

// Get the default database
GraphDatabaseService graphDb = managementService.database("neo4j");

// Create and execute transactions
try (Transaction tx = graphDb.beginTx()) {
    // Create nodes with labels and properties
    Node alice = tx.createNode(label("Person"));
    alice.setProperty("name", "Alice");
    alice.setProperty("age", 30);
    
    Node bob = tx.createNode(label("Person"));
    bob.setProperty("name", "Bob");
    bob.setProperty("age", 25);
    
    // Create relationships with properties
    Relationship friendship = alice.createRelationshipTo(bob, withName("FRIENDS"));
    friendship.setProperty("since", "2020-01-15");
    
    tx.commit();
}

// Execute Cypher queries
try (Transaction tx = graphDb.beginTx()) {
    String query = "MATCH (p:Person)-[r:FRIENDS]->(f:Person) RETURN p.name, f.name, r.since";
    tx.execute(query).forEachRemaining(record -> {
        System.out.println(record.get("p.name") + " is friends with " + record.get("f.name"));
    });
    tx.commit();
}

// Shutdown
managementService.shutdown();

Architecture

Neo4j Community Edition is built around several key components:

  • Database Management Service: Controls database lifecycle, creation, and management of multiple databases
  • Graph Database Service: Provides access to a specific graph database instance for transactions and queries
  • Transaction Management: ACID-compliant transaction system ensuring data consistency and isolation
  • Property Graph Model: Nodes and relationships with typed properties supporting complex data structures
  • Cypher Query Engine: Declarative graph query language for expressive pattern matching and data manipulation
  • Schema Management: Index and constraint management for query optimization and data integrity
  • Event System: Comprehensive event handling for monitoring database and transaction lifecycle changes

Capabilities

Database Management

Core database lifecycle management including creating databases, managing multiple database instances, and controlling database services with full ACID transaction support.

class DatabaseManagementServiceBuilder {
    DatabaseManagementServiceBuilder(Path databaseDirectory);
    <T> DatabaseManagementServiceBuilder setConfig(Setting<T> setting, T value);
    DatabaseManagementServiceBuilder loadPropertiesFromFile(Path path);
    DatabaseManagementService build();
}

interface DatabaseManagementService {
    GraphDatabaseService database(String databaseName);
    void createDatabase(String databaseName);
    void dropDatabase(String databaseName);
    List<String> listDatabases();
    void shutdown();
}

Database Management

Graph Database Operations

Core graph database functionality providing transaction management, node and relationship operations, and direct access to the graph data model with property management.

interface GraphDatabaseService {
    Transaction beginTx();
    Transaction beginTx(long timeout, TimeUnit unit);
    void executeTransactionally(String query);
    <T> T executeTransactionally(String query, Map<String, Object> parameters, 
                                ResultTransformer<T> resultTransformer);
    boolean isAvailable();
}

interface Transaction extends AutoCloseable {
    void commit();
    void rollback();
    Node createNode();
    Node createNode(Label... labels);
    Result execute(String query);
    Result execute(String query, Map<String, Object> parameters);
    Schema schema();
}

Graph Database Operations

Graph Data Model

Property graph model with nodes, relationships, labels, and properties. Provides the foundational data structures for representing and manipulating connected data.

interface Node extends Entity {
    Relationship createRelationshipTo(Node otherNode, RelationshipType type);
    Iterable<Relationship> getRelationships();
    Iterable<Relationship> getRelationships(RelationshipType... types);
    boolean hasLabel(Label label);
    void addLabel(Label label);
    void removeLabel(Label label);
}

interface Relationship extends Entity {
    Node getStartNode();
    Node getEndNode();
    Node getOtherNode(Node node);
    RelationshipType getType();
}

interface Entity {
    Object getProperty(String key);
    void setProperty(String key, Object value);
    boolean hasProperty(String key);
    void removeProperty(String key);
    Iterable<String> getPropertyKeys();
}

Graph Data Model

Query Execution

Cypher query execution with result handling, parameter binding, and execution plan analysis. Supports both transactional and auto-commit query execution patterns.

interface Result extends AutoCloseable {
    boolean hasNext();
    Map<String, Object> next();
    void forEachRemaining(Consumer<Map<String, Object>> action);
    QueryStatistics getQueryStatistics();
    ExecutionPlanDescription getExecutionPlanDescription();
}

interface ResultTransformer<T> {
    T apply(Result result) throws Exception;
}

Query Execution

Schema Management

Database schema operations including index creation, constraint management, and schema inspection for query optimization and data integrity enforcement.

interface Schema {
    IndexCreator indexFor(Label label);
    ConstraintCreator constraintFor(Label label);
    Iterable<IndexDefinition> getIndexes();
    Iterable<ConstraintDefinition> getConstraints();
    IndexState getIndexState(IndexDefinition index);
}

interface IndexCreator {
    IndexCreator on(String propertyKey);
    IndexDefinition create();
}

interface ConstraintCreator {
    ConstraintCreator assertPropertyIsUnique(String propertyKey);
    ConstraintDefinition create();
}

Schema Management

Stored Procedures and Functions

Framework for creating custom Cypher-callable procedures and functions with dependency injection, supporting READ, WRITE, SCHEMA, and DBMS execution modes.

@interface Procedure {
    String name() default "";
    Mode mode() default Mode.READ;
    boolean deprecated() default false;
}

@interface UserFunction {
    String name() default "";
    boolean deprecated() default false;
}

@interface Context {
}

enum Mode {
    READ, WRITE, SCHEMA, DBMS
}

Procedures and Functions

Event Handling

Comprehensive event system for monitoring database lifecycle, transaction events, and data changes with support for custom event listeners and transaction data inspection.

interface TransactionEventListener<T> {
    T beforeCommit(TransactionData data, Transaction transaction) throws Exception;
    void afterCommit(TransactionData data, T state, Transaction transaction);
    void afterRollback(TransactionData data, T state, Transaction transaction);
}

interface DatabaseEventListener {
    void databaseCreate(DatabaseEventContext eventContext);
    void databaseDrop(DatabaseEventContext eventContext);
    void databaseStart(DatabaseEventContext eventContext);
    void databaseShutdown(DatabaseEventContext eventContext);
}

Event Handling

Configuration

Type-safe configuration system with validation, default values, and property file loading for customizing database behavior, performance, and security settings.

interface Setting<T> {
    String name();
    T defaultValue();
    String description();
}

class GraphDatabaseSettings {
    public static final Setting<Path> data_directory;
    public static final Setting<Duration> transaction_timeout;
    public static final Setting<Long> heap_initial_size;
    // ... many more settings
}

Configuration

Traversal and Path Finding

Graph traversal framework providing programmatic path finding, relationship filtering, and bidirectional traversal with customizable evaluation criteria and path expansion strategies.

interface TraversalDescription {
    TraversalDescription relationships(RelationshipType relationshipType);
    TraversalDescription depthFirst();
    TraversalDescription breadthFirst();
    Traverser traverse(Node startNode);
}

interface Traverser extends Iterable<Path> {
    Iterable<Node> nodes();
    Iterable<Relationship> relationships();
}

interface Path {
    Node startNode();
    Node endNode();
    int length();
    Iterable<Node> nodes();
    Iterable<Relationship> relationships();
}

Traversal

Spatial Data Types

Geographic and geometric data support with point representations, coordinate systems, and spatial operations for location-aware graph applications.

interface Point {
    CRS getCRS();
    List<Coordinate> getCoordinates();
    int getDimension();
    int getSRID();
}

interface CRS {
    int getCode();
    String getType();
    Map<String, Object> getProperties();
}

interface Coordinate {
    double getCoordinate();
}

Spatial Data Types