如何计算Neo4j中的关系数 [英] How to count the number of relationships in Neo4j
本文介绍了如何计算Neo4j中的关系数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Neo4j 2.0,并使用以下查询来查找来自特定节点的特定关系的数量.
I am using Neo4j 2.0 and using the following query to find out the count of number of a particular relationship from a particular node.
我必须检查特定节点PERSON上名为"LIVES"的关系的数量.
I have to check the number of relationships named "LIVES" from a particular node PERSON.
我的查询是:
match (p:PERSON)-[r:LIVES]->(u:CITY) where count(r)>1
return count(p);
显示的错误是:
SyntaxException: Invalid use of aggregating function count(...)
我应该如何纠正?
推荐答案
您想要的版本是?人们住在一个以上的城市?
What you want is a version of having? People living in more than one city?
MATCH (p:PERSON)-[:LIVES]->(c:CITY)
WITH p,count(c) as rels, collect(c) as cities
WHERE rels > 1
RETURN p,cities, rels
这篇关于如何计算Neo4j中的关系数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文