IT评测·应用市场-qidao123.com

标题: Neo4j [打印本页]

作者: 惊雷无声    时间: 2022-8-9 14:43
标题: Neo4j
  1. docker run -it -d \
  2.     --publish=7474:7474 --publish=7687:7687 \
  3.     --volume=/home/abc/neo4jdata:/data \
  4.     --volume=/home/abc/neo4jimport:/var/lib/neo4j/import \
  5.     neo4j
  6. #neo4j
  7. LOAD CSV WITH HEADERS FROM "file:///user.txt" AS row
  8. CREATE (:UserPerson {id: row.id, user_id: row.user_id, user_name: row.user_name});
  9. CREATE INDEX ON :UserPerson(id);
  10. LOAD CSV WITH HEADERS FROM "file:///gx.txt" AS row
  11. MATCH (entity1:UserPerson{id:row.father_id}) , (entity2:UserPerson{id:row.id})
  12. create (entity1)-[r:gx]->(entity2)
  13. //返回 张莱柠 下三层数据
  14. MATCH p=(n:UserPerson{user_name:'张莱柠'})-[*..3]->() return p
  15. //返回 张莱柠 下最深的路径
  16. MATCH path=(person:UserPerson)-[:gx*]->(x)
  17. WHERE person.user_name = '张莱柠' AND NOT EXISTS((x)-[:gx]->())
  18. WITH person, path
  19. ORDER BY LENGTH(path) DESC
  20. LIMIT 1
  21. RETURN person, [n IN NODES(path) | n.user_name] AS ids, LENGTH(path) AS depth
  22. //返回 下所有子节点
  23. MATCH path=(person:UserPerson)-[:gx*]->(x)
  24. WHERE person.user_name = '张莱柠'
  25. return count(x)
  26. # 使用函数,查询张莱柠与张三的最短路径
  27. match p=shortestpath((:UserPerson{user_name:"张莱柠"})-[*..5]->(:UserPerson{user_name:"张三"})) return p;
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!




欢迎光临 IT评测·应用市场-qidao123.com (https://dis.qidao123.com/) Powered by Discuz! X3.4