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

dwj*_*ton 5 cypher

这是我正在尝试的:

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

我懂了

QueryExecutionKernelException: Invalid use of aggregating function count(...) in this context
Run Code Online (Sandbox Code Playgroud)

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

cec*_*ode 5

找出彼此之间的联系不仅仅是通过关系,例如:

  • 一个喜欢b
  • 一个知道b
  • a与b同住

使用

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

但是,如果您要查找以链状关系联系的人(朋友的朋友)

  • 一个知道b
  • b知道c
  • c喜欢d
  • d知道e

而您想找到一个到d,则可以使用类似

MATCH (n:Person)-[r*1..3]->(m:Person)
RETURN *
Run Code Online (Sandbox Code Playgroud)

相关教程希尔