惊雷无声 发表于 2022-8-9 14:43:38

Neo4j

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)-->(entity2)
//返回 张莱柠 下三层数据
MATCH p=(n:UserPerson{user_name:'张莱柠'})-[*..3]->() return p
//返回 张莱柠 下最深的路径
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, 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;
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
页: [1]
查看完整版本: Neo4j