我正在尝试从顶部列表和底部列表中创建循环关系。我正在尝试将顶部循环与底部循环连接。我非常感谢任何帮助。谢谢。
UNWIND [{id:"1",name:"b1",year:"2010"},
{id:"2",name:"d1",year:"2011"},
{id:"3",name:"e1",year:"2013"}] as user
MERGE (u:User {id: user.id, name: user.name,year:user.year})
UNWIND [{id:"21",name:"b",year:"2010"},
{id:"41",name:"d",year:"2011"},
{id:"51",name:"e",year:"2013"}] as w
MERGE (y:W {id: w.id, name: w.name,year:w.year})
MERGE (u)-[:SHARE]->(y)
错误:
WITH is required between MERGE and UNWIND (line 8, column 1 (offset: 192))
"unwind [{id:"21",name:"b",year:"2010"},"
^
Neo.ClientError.Statement.InvalidSyntax
答案 0 :(得分:3)
如果您尝试将所有User
个节点连接到所有W
个节点,那么您只需切换第一个MERGE
和第二个UNWIND
}:
UNWIND [{id:"1",name:"b1",year:"2010"},
{id:"2",name:"d1",year:"2011"},
{id:"3",name:"e1",year:"2013"}] as user
UNWIND [{id:"21",name:"b",year:"2010"},
{id:"41",name:"d",year:"2011"},
{id:"51",name:"e",year:"2013"}] as w
MERGE (u:User {id: user.id, name: user.name,year:user.year})
MERGE (y:W {id: w.id, name: w.name,year:w.year})
MERGE (u)-[:SHARE]->(y)
答案 1 :(得分:2)
在这里你可以做些什么,但我必须同意@Brian你最好按照他的评论以编程方式生成这些陈述。
WITH [{id:"1",name:"b1",year:"2010"},
{id:"2",name:"d1",year:"2011"},
{id:"3",name:"e1",year:"2013"}] as user,
[{id:"21",name:"b",year:"2010"},
{id:"41",name:"d",year:"2011"},
{id:"51",name:"e",year:"2013"}] as w
foreach (i in range(0,length(user)-1) |
MERGE (u:User {id: (user[i]).id, name: (user[i]).name,year:(user[i]).year})
MERGE (y:W {id: (w[i]).id, name: (w[i]).name,year:(w[i]).year})
MERGE (u)-[:SHARE]->(y))