Neo4j:迭代关系集合并将属性设置为索引

时间:2015-03-31 02:22:51

标签: neo4j

在(i等){...}样式的经典中,我想迭代一个有序集合 - 伪代码:

for n,i in nodes
  set node.weight = i + 1
end

可行?

1 个答案:

答案 0 :(得分:4)

是的,但不是最漂亮的事情:

MATCH ...
WITH COLLECT(something) AS nodes
FOREACH(i IN RANGE(0, LENGTH(nodes)) |
    FOREACH(node IN [nodes[i]] |
        SET node.weight = i + 1
))