繁体   English   中英

Neo4j / Cypher从多个嵌套的json创建节点

[英]Neo4j/Cypher Create nodes from multiple nested json

我正在尝试从下面的示例数据创建图形。 我是cypher的新手,并从教程和堆栈帮助中学习了新东西。 我陷入下面的问题。 我正在尝试从嵌套数组中为多个属性创建节点。

单击链接: 取消从JSON文件加载的多个不相关的数组

样本数据:

[   {   'organization': ['MIT','Univ. of CT'],
        'student_names': ['Adam Smith'],
        'unique_id': 'ABC123'},
    {   'organization': ['Harvard'],
        'student_names': ['Adam Smith', 'Cate Scott'],
        'unique_id': 'ABC124'},
    {   'organization': ['Harvard'],
        'student_names': ['Mandy T.', 'Bob Smith'],
        'unique_id': 'ABC125'}]

这是我尝试过的:

CALL apoc.load.json('file:///test2.json') YIELD value AS class
MERGE (c:Class {name: class.name})
SET
c.organization = class.organization,
c.student_names = class.student_names

WITH c, class
UNWIND class.organization AS org
MERGE (o:Organization {name: org})
MERGE (o)-[:ACCEPTED]->(c)

WITH c, class
UNWIND class.student_names AS student
MERGE (s:StudentName {name: student})
MERGE (s)-[:ATTENDS]->(o)

我不断收到错误Neo.ClientError.Statement.SemanticError: Cannot merge node using null property value for name 我在数据中看不到任何空值。 是什么原因造成的? 我怎样才能解决这个问题? 谢谢!!!

如果您要合并的属性具有空值,则MERGE不起作用。

在这里,使用MERGE (c:Class {name: class.name})您正在尝试在属性名称上合并Class节点,但是json中没有这样的属性。

我猜您想将其合并在unique_id属性上。 所以你可以改变你的

MERGE (c:Class {unique_id: class.unique_id})

其余查询看起来还可以。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM