我试图找到具有多个传入关系的所有节点。鉴于此数据:
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;
我在这一切都错了吗?
最佳答案
这对你有用吗?
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;
关于neo4j - 查找具有多个传入关系的 neo4j 节点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22998090/