简体   繁体   English

找到具有多个传入关系的neo4j节点

[英]Find neo4j nodes with more than one incoming relationship

I'm trying to find all the nodes with more than one incoming relationship. 我正在尝试找到具有多个传入关系的所有节点。 Given this data: 鉴于此数据:

a-[has]->b
a-[has]->c
d-[has]->b

So, I'm looking for a query that returns 'b', because it has more that one incoming. 所以,我正在寻找一个返回'b'的查询,因为它有更多的传入。

This query is close. 此查询已结束。 It returns 'a' and 'b', because they both have 2 relations: 它返回'a'和'b',因为它们都有2个关系:

match (n)--()
with n,count(*) as rel_cnt
where rel_cnt > 1
return n;

However, this query (the addition of '-->') doesn't return any and I don't know why: 但是,此查询(添加' - >')不返回任何内容,我不知道原因:

match (n)-->()
with n,count(*) as rel_cnt
where rel_cnt > 1
return n;

Am I going about this all wrong? 我错了吗?

Does this work for you? 这对你有用吗?

MATCH ()-[r:has]->(n)
WITH n, count(r) as rel_cnt
WHERE rel_cnt > 1
RETURN n;

I am assuming, perhaps incorrectly, that 'has' is the appropriate relationship type. 我假设,或许是错误的,'has'是适当的关系类型。 If not, then try: 如果没有,那么试试:

MATCH ()-[r]->(n)
WITH n, count(r) as rel_cnt
WHERE rel_cnt > 1
RETURN n;

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

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