返回考慮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 –