【问题标题】:Neo4j: Create slef relation cypher queryNeo4j:创建 slef 关系密码查询
【发布时间】:2014-11-22 14:27:32
【问题描述】:

我有大量 EmpBase 导入(来自 postgreSQL 的 csv 文件)节点,例如:

neo4j-sh (?)$ match (e:EmpBase) return e limit 10;
+-------------------------------------------------------------------------+
| e                                                                       |
+-------------------------------------------------------------------------+
| Node[8992]{neo_eb_id:8993,neo_eb_name:"emp_no_8993",neo_eb_bossID:5503} |
| Node[8993]{neo_eb_id:8994,neo_eb_name:"emp_no_8994",neo_eb_bossID:8131} |
| Node[8994]{neo_eb_id:8995,neo_eb_name:"emp_no_8995",neo_eb_bossID:8624} |

什么密码查询可以在每个节点上创建自我关系,以便每个具有neo_eb_bossid 的节点都可以与适当的节点建立关系?

在 postgreSQl 中,数据大约是 1020MB 表。在 Neo4j 中,导入后,控制台显示为 6.42 GiB。

【问题讨论】:

    标签: neo4j cypher relationships


    【解决方案1】:

    为了创建基于 neo_eb_bossID 的关系,您可以匹配节点并运行一个 foreach 循环来创建与相关节点的关系:

    MATCH (e:EmpBase) WITH collect(e) AS empbases
    FOREACH (emp in empbases |
        MERGE (target:EmpBase {neo_eb_id:emp.neo_eb_bossID}
        MERGE (emp)-[:YOUR_RELATIONSHIP]->(target)
    )
    

    关于自我关系,我很难理解你到底想要什么。

    克里斯

    【讨论】:

      猜你喜欢
      • 2012-09-30
      • 1970-01-01
      • 2013-09-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多