在Neo4j cypher中计算和操作

时间:2014-10-07 13:08:01

标签: count neo4j cypher

我正在尝试一个查询,如下所示:

MATCH (g:GNE)-[:like]->(c:CLUSTER)<-[:Belong]-(h:GNE) 
WHERE g.sym = 'ST1' AND count(c) >=4  
RETURN h.sym, count(c) AS score, collect(c.clustInfo), h.chr ORDER BY score DESC 

但表达式&#39; count(c)&gt; = 4&#39;不工作...... 有什么建议吗?

1 个答案:

答案 0 :(得分:3)

您不能直接在WHERE子句中使用聚合,您需要使用WITH创建一个新变量,以便在后续条件下进行测试。您的查询变为:

MATCH (g:GNE{sym:"ST1"})-[:like]->(c:CLUSTER)<-[:Belong]-(h:GNE) 
WITH h, COUNT(c) AS score, COLLECT(c.clusterInfo) AS info
ORDER BY score DESC
WHERE score >= 4
RETURN h.sym, score, info, h.chr