想象一个节点与另一个节点有两种类型的关系,而第三个节点只有一种类型。例如,在手册(http://docs.neo4j.org/chunked/milestone/query-match.html#match-match-by-multiple-relationship-types)中,假设Node7还与Node4 [DIRECTED]有额外的关系 - 所以道格拉斯同时执行并指导“美国总统”。
如何找到(在cypher中)与node7相关的所有节点,只关于ACTED的关系类型,而不是显示与ACTED相关的节点还包含其他关系?
答案 0 :(得分:1)
这是怎么回事?
start n=node(3084)
match n-[r]-m // might want to have direction?
with collect(r) as collr, m // collect the relationships
where length(collr) = 1 // we only want nodes with 1 relationship
and type(head(collr)) = "ACTED" // and the one relationship needs to be ACTED (I think it's actually ACTS_IN in the example dataset)
return m;