返回考虑follwing CQL查询UNWIND不Neo4j的
MATCH (n:Label1) WITH n
OPTIONAL MATCH (n)-[r:REL_1]-(:Label2 {id: 5})
WHERE r is NULL OR r.d < 12345 OR (r.d = 12345 OR r.c < 2)
WITH n,r LIMIT 100
WITH COLLECT({n: n, r: r}) AS rows
MERGE (c:Label2 {id: 5})
WITH c,
[b IN rows WHERE b.r.d IS NULL OR b.r.d < 12345] AS null_less_rows,
[c IN rows WHERE (c.r.d = 12345 AND c.r.c < 2)] AS other_rows
WITH null_less_rows, other_rows, c, null_less_rows+other_rows AS rows, size(null_less_rows+other_rows) AS count
UNWIND null_less_rows AS null_less_row
MERGE(s:Label1 {id: null_less_row.n.id})
MERGE(s)-[:REL_1 {d: 12345, c: 1}]->(c)
WITH DISTINCT other_rows, c, rows, count
UNWIND other_rows AS other_row
MATCH(s:Label1 {id: other_row.n.id})-[str:REL_1]->(c) SET str.c = str.c + 1
WITH rows, count
RETURN rows, count
当我EXCUTE查询,它应该返回行(按查询)计数。但是不要返回行,请将其计为结果语句。
Set 200 properties, created 100 relationships, statement completed in 13 ms.
查询结构是否存在任何问题或使用UNWIND子句时出现问题。
尝试插入'RETURN other_rows,行,最后'MERGE'后count'(和评论毕竟)。结果会是什么?附:对于未来:如果您要求帮助理解复杂的查询 - 举例说明可以检查此查询的输入数据。 http://stackoverflow.com/help/mcve –