我试图通过匹配数据库中的现有节点来从JSON数据创建关系。具体来说,我在neo4j实例中有人员节点,并且有一个与其工作相对应的数据集。我想从人员节点到作业节点添加关系。
JSON数据如下:
{"id": "1", "name": "Picasso", "job": {"raw": "Painter"}}
{"id": "2", "name": "Beyonce", "job": {"raw": "Singer"}}
{"id": "3", "name": "Derek Jeter", "job": {"raw": "Baseball Player"}}
我的密码查询:
CALL apoc.load.json('file:/example.txt') YIELD value AS q
MATCH (p:Person {id:q.id})
WITH q, p
UNWIND q.job as job
WITH DISTINCT p, job
MERGE (j:Job {name: job.raw})
MERGE (p)-[:WORKS_AT_JOB]->(j)
但是,对于某些Person节点,我得到了重复的关系。我在做什么错了?