我有以下密码查询 -
MATCH(from: GContact)
WHERE NOT from:migrationComplete
WITH from
LIMIT 10
SET from:migrationComplete
WITH from, COUNT(from) AS booleanCount
MATCH (from)-[r:has]->(to: GEmail)
WITH from, to, booleanCount
MERGE (from)-[r:contactHasEmail]->(to)
RETURN booleanCount
我希望查询返回from
之后找到的SET
的数量,即<=10
。
但是,查询返回MATCH (from)-[r:has]->(to: GEmail)
中找到的匹配数。有没有办法将原始计数一直传递并返回?
答案 0 :(得分:0)
您不能将聚合和未聚合的值作为一般事实返回。
但您可以使用collect:
再次聚合和分发MATCH(from: GContact)
WHERE NOT from:migrationComplete
WITH from
LIMIT 10
SET from:migrationComplete
WITH COLLECT(from) AS nodes
UNWIND nodes as from
WITH from, size(nodes) AS booleanCount
MATCH (from)-[r:has]->(to: GEmail)
WITH from, to, booleanCount
MERGE (from)-[r:contactHasEmail]->(to)
RETURN booleanCount
您也可以在最后使用RETURN count(distinct from) as booleanCount