我有一个子图,节点类型c与t1和t2有关系。节点t1与w1和w2有关系。节点t2与w1有关系。
我想用cypher查询的是从节点c返回有2个或更多t节点相关的w节点。即仅限w1。
显然你不能在WHERE子句中聚合,如
START c=node(7)
MATCH (c)-[:T_TO]-(t)-[:W_TO]-(w)
WHERE COUNT(t) >= 2
RETURN w.WName;
也许以另一种方式看待它,这也不起作用,因为我只想要与t1和t2相关的w?...
START c=node(7), t1=node(10), t2=node(8)
MATCH (c)-[:T_TO]-(t)-[:W_TO]-(w)
WHERE t in [t1, t2]
RETURN t, w.WName;
更新 任何想要像第二个一样的人,这都有效:
START c=node(7), t1=node(8), t2=node(10)
MATCH (c)-[:T_TO]-(t1)-[:W_TO]-(w),(c)-[:T_TO]-(t2)-[:W_TO]-(w)
RETURN w.WName;
答案 0 :(得分:1)
怎么样
START c=node(7)
MATCH (c)-[:T_TO]-(t)-[:W_TO]-(w)
WITH COUNT(t) as tCount,w
WHERE tCount >= 2
RETURN w.WName;