用foreach创建节点之间的关系

时间:2014-01-29 10:01:13

标签: neo4j

我必须使用istat标签在节点和所有节点之间建立关系;所以尝试了这个查询: START MATCH (i:istat), c = node(21519) FOREACH(i|CREATE UNIQUE (c)-[r:CAN_SEE]->(i); 但是控制台给了我这个错误:

    SyntaxException: Invalid input 'u': expected whitespace, comment, NodeLabel, MapLiteral, a parameter, a relationship pattern, '.', '[', "=~", IN, IS, '*', '/', '%', '^', '+', '-', '<', '>', "<=", ">=", '=', "<>", "!=", AND, XOR, OR or '|' (line 1, column 101)
==> "start c =node(21519) match(i:istat) with collect(i) as istat_code,n foreach(i in istat_code: create unique (n)-[r:CAN_SEE]->(i))"
==>                                                                                                      ^

1 个答案:

答案 0 :(得分:1)

试试这个

START c=node(21519)
MATCH(i:istat) WITH c,collect(i) AS istat_code 
FOREACH(t in istat_code | CREATE UNIQUE (c)-[r:CAN_SEE]->(t))