看起来像一个简单的错误,但我无法找到任何具体的信息,所以希望你能够了解这里发生的事情。
基本上我正在尝试迭代两组数据,为第一组创建元素,并根据某些条件将它们与第二组中的元素相关联。条件检查也是通过“foreach技巧”进行的,因此有2级嵌套FOREACH
的
FOREACH (plc IN [{name:'bar2',id:'pepe'},{name:'foo2',id:'papa'},{name:'foo3',id:'paps'}] |
MERGE (place:Place {id:plc.id})
ON CREATE SET place = plc
FOREACH (evt IN [{placename:'foo2',id:'pewpew'},{placename:'foo2',id:'powpow'},{placename:'bar2',id:'pawpaw'},{placename:'bar2',id:'pwaaagh'},{placename:'foo3',id:'pwaaagh'}] |
FOREACH (ignoreme in CASE WHEN evt.placename = plc.name THEN [1] ELSE [] END |
CREATE (e:Event)-[rel:IN]->(place)
SET e=evt
)))
快乐地咯咯地笑着Neo4j
向我发出Unknown identifier "e"
答案 0 :(得分:2)
我建议您在UNWIND
之前使用FOREACH
进行尝试。
WITH
[{name:'bar2',id:'pepe'},{name:'foo2',id:'papa'},{name:'foo3',id:'paps'}] AS plcs,
[{placename:'foo2',id:'pewpew'},{placename:'foo2',id:'powpow'},{placename:'bar2',id:'pawpaw'},{placename:'bar2',id:'pwaaagh'},{placename:'foo3',id:'pwaaagh'}] AS evts
UNWIND plcs AS plc
MERGE (place:Place {id:plc.id})
WITH place, plc, evts
UNWIND evts AS evt
WITH place, plc, evt
WHERE evt.placename = plc.name
CREATE (e:Event)-[:IN]->(place)
SET e=evt
答案 1 :(得分:1)
似乎是一个错误。
您可以通过将较长的创建模式拆分为两个来解决它,以便创建e
变量。
FOREACH (plc IN [{name:'bar2',id:'pepe'},{name:'foo2',id:'papa'},{name:'foo3',id:'paps'}] |
MERGE (place:Place {id:plc.id})
ON CREATE SET place = plc
FOREACH (evt IN [{placename:'foo2',id:'pewpew'},{placename:'foo2',id:'powpow'},{placename:'bar2',id:'pawpaw'},{placename:'bar2',id:'pwaaagh'},{placename:'foo3',id:'pwaaagh'}] |
FOREACH (ignoreme in CASE WHEN evt.placename = plc.name THEN [1] ELSE [] END |
CREATE (e:Event)
CREATE (e)-[rel:IN]->(place)
SET e=evt
)))