【问题标题】:Find neo4j nodes with more than one incoming relationship查找具有多个传入关系的 neo4j 节点
【发布时间】:2014-05-24 18:04:27
【问题描述】:

我正在尝试查找具有多个传入关系的所有节点。鉴于此数据:

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

所以,我正在寻找一个返回“b”的查询,因为它有多个传入。

此查询已关闭。它返回 'a' 和 'b',因为它们都有 2 个关系:

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

但是,这个查询(添加'-->')没有返回任何内容,我不知道为什么:

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

这一切都错了吗?

【问题讨论】:

    标签: neo4j cypher


    【解决方案1】:

    这对你有用吗?

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

    我假设(也许是错误的)“有”是合适的关系类型。如果没有,请尝试:

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

    【讨论】:

    • 谢谢,您的查询和我的原始查询都有效。事实证明我没有正确创建节点,并且我有 2 个节点名为 a。我想这是一个新手错误。
    猜你喜欢
    • 1970-01-01
    • 2016-01-25
    • 2017-07-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-29
    • 1970-01-01
    相关资源
    最近更新 更多