如何在Cypher中对COUNT执行WHERE子句?

时间:2015-07-09 23:51:35

标签: cypher

这就是我正在尝试的:

match 
(e:Person) - [r] - (f:Person) 
where (count(r) > 5 AND count (r) <10) 
return id(e), e.name; 

我得到了

QueryExecutionKernelException: Invalid use of aggregating function count(...) in this context

基本上我想找一个与5到10个其他人有关的人。

1 个答案:

答案 0 :(得分:4)

通过关系来找出彼此联系的人 例如:

  • a like b
  • 知道b
  • a lives_with b

使用

match (a:Person)-[r]-(b:person)
with a,b,count(r) as cnt
where cnt > 5 and cnt < 10
return *

如果你想找到作为连锁店(朋友的朋友)连接的人

  • 知道b
  • b知道c
  • c喜欢d
  • d know e

你想要找到一个到d然后你可以使用像

这样的东西
MATCH (n:Person)-[r*1..3]->(m:Person)
RETURN *

相关教程heer