如何匹配具有超过 1 个指定关系的节点 [英] How to MATCH nodes with with more than 1 of a specified relationship

查看:43
本文介绍了如何匹配具有超过 1 个指定关系的节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在 Neo4j 中找到所有 Datum 节点,其中有超过 1 个 GOLDSOURCEFEED 关系指向它.我不在乎什么类型的节点有关系.这是基本查询,您可以查看节点变量等.

I'm trying to find all Datum nodes in Neo4j where there is more than 1 of the GOLDSOURCEFEED relationships pointing to it. And I don't care what type of node has the relationship. Here's the base query just so you can see the node variables etc.

MATCH (p:Datum)<-[:GOLDSOURCEFEED]-()
WHERE exists ( (p:Datum)<-[:GOLDSOURCEFEED]-() )
RETURN p.name

显然,当我放入上面的列表时,我得到了所有具有 GOLDSOURCEFEED 关系的 Datum 节点,我想对其进行细化以仅列出存在多个 GOLDSOURCEFEED 关系的地方.

Obviously when I put in the list above, I get all of the Datum nodes that have a GOLDSOURCEFEED relationship, I want to refine that to only list where there's more than one GOLDSOURCEFEED relationship.

推荐答案

您应该使用有效的度数检查:

You should use an efficient degreeness check:

MATCH (p: Datum)
WHERE SIZE((p)<-[:GOLDSOURCEFEED]-()) > 1 
RETURN p.name;

度数检查只是使用每个节点已经可用的数据,而不需要实际获取路径.当您不关心关系另一端的节点或任何关系属性时,可以执行度数检查.

A degreeness check simply uses data already available for each node, and does not require actually getting the paths. It is possible to perform a degreeness check when you do not care about the node on the opposite end of the relationship or any relationship properties.

这篇关于如何匹配具有超过 1 个指定关系的节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆