Scripts2026年4月11日·1 分钟阅读

Neo4j — The Leading Native Graph Database

Neo4j is the leading native graph database, providing an ACID-compliant transactional backend for powerful graph queries via the Cypher query language. Used by NASA, eBay, Airbnb, and thousands of apps needing relationship-heavy data.

SC
Script Depot · Community
快速使用

先拿来用,再决定要不要深挖

这里应该同时让用户和 Agent 知道第一步该复制什么、安装什么、落到哪里。

# Docker
docker run -d --name neo4j -p 7474:7474 -p 7687:7687 \
  -e NEO4J_AUTH=neo4j/tokrepo12345 \
  -v neo4j-data:/data \
  neo4j:5-community

# Browser UI at http://localhost:7474
# Bolt protocol at bolt://localhost:7687

Cypher queries (via browser or cypher-shell):

// Create nodes and relationships
CREATE (w:User { name: "William", role: "founder" })
CREATE (t:Product { name: "TokRepo" })
CREATE (w)-[:FOUNDED { year: 2025 }]->(t)

// Query: who founded what
MATCH (u:User)-[r:FOUNDED]->(p:Product)
RETURN u.name, p.name, r.year

// Find friends of friends (classic graph query)
MATCH (me:User { name: "William" })-[:KNOWS*2]-(fof:User)
WHERE fof.name <> "William"
RETURN DISTINCT fof.name

// Shortest path
MATCH path = shortestPath((a:City { name: "Shenzhen" })-[*]-(b:City { name: "Beijing" }))
RETURN path

// Indexes
CREATE INDEX user_name FOR (u:User) ON (u.name)
介绍

Neo4j is the leading native graph database, providing a property graph model with ACID transactions, the declarative Cypher query language, and a high-performance graph storage engine. Founded in 2007 by Emil Eifrem. Used by NASA, Airbnb, eBay, Comcast, and thousands of apps where relationships between entities matter more than individual records.

What Neo4j Does

  • Property graph — nodes, relationships, both with properties
  • Cypher — SQL-like declarative query language (now ISO GQL standard)
  • Index-free adjacency — constant-time traversal regardless of graph size
  • ACID transactions — full consistency guarantees
  • Clustering — Enterprise causal clustering for HA
  • Graph algorithms — via Graph Data Science (GDS) library
  • Vector search — Neo4j 5.11+ built-in vector indexes for RAG
  • GraphQL — Neo4j GraphQL library to generate API

Architecture

Native graph storage: nodes and relationships are first-class records on disk with direct pointers (index-free adjacency). Query engine compiles Cypher to an execution plan that walks the graph. Bolt binary protocol for driver communication.

Self-Hosting

# docker-compose.yml
version: "3"
services:
  neo4j:
    image: neo4j:5-community
    ports: ["7474:7474", "7687:7687"]
    volumes:
      - neo4j-data:/data
      - neo4j-logs:/logs
    environment:
      NEO4J_AUTH: neo4j/tokrepo12345
      NEO4J_server_memory_heap_max__size: 2G
      NEO4J_PLUGINS: "[\"apoc\", \"graph-data-science\"]"
volumes:
  neo4j-data:
  neo4j-logs:

Key Features

  • Native property graph storage
  • Cypher query language
  • ACID transactions
  • Graph Data Science library (65+ algorithms)
  • Vector indexes for AI/RAG
  • Neo4j Browser UI
  • Bolt binary protocol
  • APOC stored procedures library
  • Causal clustering (Enterprise)
  • Fabric for multi-database queries

Comparison

Graph DB Query Lang Type Storage
Neo4j Cypher Property graph Native
ArangoDB AQL Multi-model Native
JanusGraph Gremlin Property graph Cassandra/HBase
TigerGraph GSQL Property graph Native
Dgraph DQL + GraphQL RDF-like Native
Memgraph Cypher Property graph In-memory
NebulaGraph nGQL Property graph Distributed

常见问题 FAQ

Q: 什么场景选图数据库? A: 社交网络、推荐系统、欺诈检测、知识图谱、依赖分析、身份认证链——任何以关系为核心的查询。

Q: Cypher vs Gremlin? A: Cypher 声明式(SQL-like),Gremlin 命令式(像程序)。Cypher 更易读、已成为 ISO GQL 标准;Gremlin 更通用(任何 TinkerPop 图)。

Q: 向量搜索? A: Neo4j 5.11+ 支持原生向量索引,可以把向量和图结构结合做 GraphRAG——图节点同时带 embedding。

来源与致谢 Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产