简体   繁体   English

在Neo4j cypher中计算和操作

[英]Count and operations in Neo4j cypher

I'm trying one query, like this: 我正在尝试一个查询,如下所示:

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 

but the expression 'count(c) >= 4' doesn't work... Any suggestions? 但表达式'count(c)> = 4'不起作用......有什么建议吗?

You cannot directly use aggregates in a WHERE clause like that, you need to use WITH to create a new variable for testing in subsequent conditions. 您不能直接在WHERE子句中使用聚合,您需要使用WITH来创建一个新变量,以便在后续条件下进行测试。 You query becomes something like: 您的查询变为类似于:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM