我有这样的边缘:
(People)-[:USE]->(Product)
(People)-[:REVIEW]->(Product)
现在我有了一个新的csv的“审阅者”,但是他们缺少了我已经拥有的某些属性。
我想做类似的事情:
LOAD CSV WITH HEADERS FROM "file:///abcd.csv" AS row
MERGE (svc:Consumer {name: row.referring_name})
ON CREATE SET
svc.skewNum = toInteger(row.skew_num)
MERGE (p:PrimaryConsumer) WHERE p.name = svc.name
ON MATCH SET
svc.city = p.city,
svc.latitude = toFloat(p.latitude),
svc.longitude = toFloat(p.longitude),
svc.consumerId = toInteger(p.primaryConsumerId)
哪个混蛋:
Neo.ClientError.Statement.SyntaxError:无效的输入“ H”:预期的“ i / I”(第10行,第28列(偏移量:346)) “合并(p:PrimaryConsumer),其中p.name = svc.name”
我100%保证名称是唯一的,并且将与现有节点集中的唯一使用者名称匹配(待观察)。
当唯一节点属性匹配时,如何将现有属性添加到新数据? (我希望获得唯一的ID,但是我必须能够在匹配时对新数据执行更新)
谢谢。
这是整个密码脚本-根据@cypher的输入进行修改。
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///abcde.csv" AS row
MERGE (svc:Consumer {name: row.referring_name})
ON CREATE SET
svc.skeyNum = toInteger(row.skew_num)
MATCH (p:primaryConsumer {name: svc:name})
ON MATCH SET
svc.city = p.city,
svc.latitude = toFloat(p.latitude),
svc.longitude = toFloat(p.longitude),
svc.providerId = toInteger(p.providerId)
MERGE (spec:Product {name: row.svc_prod_name})
ON CREATE SET
spec.name = row.svc_prov_name,
spec.skew = toInteger(row.skew_id),
spec.city = row.svc_prov_city,
spec.totalAllowed = toFloat(row.total_allowed)
MERGE (svc)-[r:CONFIRMED_PURCHASE]->(spec)
ON MATCH SET r.totalAllowed = r.totalAllowed + spec.totalAllowed
ON CREATE SET r.totalAllowed = spec.totalAllowed
;
答案 0 :(得分:2)
MERGE
不接受WHERE
子句。
更改此:
MERGE (p:PrimaryConsumer) WHERE p.name = svc.name
对此:
MERGE (p:PrimaryConsumer {name: svc.name})
[编辑]
整个查询应如下所示:
LOAD CSV WITH HEADERS FROM "file:///abcd.csv" AS row
MERGE (svc:Consumer {name: row.referring_name})
ON CREATE SET
svc.skewNum = toInteger(row.skew_num)
MERGE (p:PrimaryConsumer {name: svc.name})
ON MATCH SET
svc.city = p.city,
svc.latitude = toFloat(p.latitude),
svc.longitude = toFloat(p.longitude),
svc.consumerId = toInteger(p.primaryConsumerId)