Reputation: 2158
I am trying to create graph from the sample data below. I am new to cypher and learned new things from tutorial and stack help. I am stuck at the problem below. I am trying to create nodes from nested arrays for multiple properties.
Following the link: UNWIND multiple unrelated arrays loaded from JSON file
Sample Data:
[ { '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'}]
Here is what I tried:
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)
I keep getting error Neo.ClientError.Statement.SemanticError: Cannot merge node using null property value for name
. I don't see any null values in the data. What is causing this? How can I fix this? Thanks!!!
Upvotes: 0
Views: 679
Reputation: 4052
MERGE doesn't work if the property on which you merging has a null value.
Here, with MERGE (c:Class {name: class.name})
You are trying merge Class node on the property name but there is no such a property in the json.
I guess you wanted to merge this on unique_id property. So you can change your as
MERGE (c:Class {unique_id: class.unique_id})
Rest of the query looks ok.
Upvotes: 1