docker run -it -d \
--publish=7474:7474 --publish=7687:7687 \
--volume=/home/abc/neo4jdata:/data \
--volume=/home/abc/neo4jimport:/var/lib/neo4j/import \
neo4j
#neo4j
LOAD CSV WITH HEADERS FROM "file:///user.txt" AS row
CREATE (:UserPerson {id: row.id, user_id: row.user_id, user_name: row.user_name});
CREATE INDEX ON :UserPerson(id);
LOAD CSV WITH HEADERS FROM "file:///gx.txt" AS row
MATCH (entity1:UserPerson{id:row.father_id}) , (entity2:UserPerson{id:row.id})
create (entity1)-[r:gx]->(entity2)
//返回 张莱柠 下三层数据
MATCH p=(n:UserPerson{user_name:'张莱柠'})-[*..3]->() return p
match (n:UserPerson{user_name:'张莱柠'})-[*..3]->(result) return count(result)
//返回所有节点含自己
match (n:UserPerson{user_name:'张莱柠'})-[*0..]->(result) return count(result)
//返回所有节点不含自己
match (n:UserPerson{user_name:'张莱柠'})-[*1..]->(result) return count(result)
//返回 张莱柠 下最深的路径
MATCH path=(person:UserPerson)-[:gx*]->(x)
WHERE person.user_name = '张莱柠' AND NOT EXISTS((x)-[:gx]->())
WITH person, path
ORDER BY LENGTH(path) DESC
LIMIT 1
RETURN person, [n IN NODES(path) | n.user_name] AS ids, LENGTH(path) AS depth
//返回 下所有子节点
MATCH path=(person:UserPerson)-[:gx*]->(x)
WHERE person.user_name = '张莱柠'
return count(x)
# 使用函数,查询张莱柠与张三的最短路径
match p=shortestpath((:UserPerson{user_name:"张莱柠"})-[*..5]->(:UserPerson{user_name:"张三"})) return p;
# 更新数据
MATCH (n:node)-[]->()
WITH n, count(*) as c
SET n.data = c