Project

lex-neo4j

0.0
The project is in a healthy, maintained state
Connects LegionIO to Neo4j graph database via HTTP Cypher transaction API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

 Project Readme

lex-neo4j

Legion Extension for Neo4j graph database via the HTTP Cypher transaction API.

Installation

gem 'lex-neo4j'

Usage

client = Legion::Extensions::Neo4j::Client.new(
  url: 'http://localhost:7474',
  username: 'neo4j',
  password: 'your-password',
  database: 'neo4j'
)

# Raw Cypher
client.query('MATCH (n:Person) RETURN n LIMIT 10')
client.query('CREATE (n:Person {name: $name}) RETURN n', parameters: { name: 'Alice' })

# Nodes
client.find_nodes(label: 'Person', properties: { name: 'Alice' })
client.create_node(label: 'Person', properties: { name: 'Bob', age: 30 })
client.merge_node(label: 'Person', match_properties: { email: 'bob@example.com' }, on_create: { created_at: Time.now.to_s })
client.count_nodes(label: 'Person')
client.list_labels

# Relationships
client.create_relationship(from_id: node1_id, to_id: node2_id, type: 'KNOWS', properties: { since: 2020 })
client.neighbors(id: node_id, direction: :outgoing, type: 'KNOWS')
client.shortest_path(from_id: node1_id, to_id: node2_id)
client.list_relationship_types

# Indexes & Constraints
client.list_indexes
client.create_index(label: 'Person', properties: ['name', 'email'], name: 'idx_person_name_email')
client.create_uniqueness_constraint(label: 'Person', property: 'email', name: 'uniq_person_email')
client.create_existence_constraint(label: 'Person', property: 'name')

# Explicit Transactions
tx = client.begin_transaction
client.execute_in_transaction(transaction_url: tx[:location], statements: ['CREATE (n:Temp) RETURN n'])
client.commit_transaction(transaction_url: tx[:location])

# Administration
client.server_info
client.list_databases
client.list_procedures
client.call_procedure(name: 'dbms.components')

# Graph Data Science (requires GDS plugin)
client.project_graph(name: 'social', node_projection: 'Person', relationship_projection: 'KNOWS')
client.run_pagerank(graph_name: 'social')
client.run_louvain(graph_name: 'social')
client.run_node_similarity(graph_name: 'social')
client.drop_graph(name: 'social')

Read-Only Mode

client = Legion::Extensions::Neo4j::Client.new(
  url: 'http://localhost:7474',
  username: 'neo4j',
  password: 'pass',
  read_only: true
)

client.find_nodes(label: 'Person')  # works
client.create_node(label: 'Person') # raises ReadOnlyError

Runners

Runner Purpose
Cypher Raw query execution, multi-statement batches
Nodes Node CRUD, merge, count, label listing
Relationships Relationship CRUD, merge, traversal, shortest path
Indexes Index and constraint management (range, fulltext, uniqueness, existence)
Transactions Explicit transaction lifecycle
Admin Server info, database management, procedures, functions
GraphDataScience GDS graph projections and algorithms (PageRank, Louvain, similarity)

License

MIT