Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Neo4j 否定多重关系_Neo4j_Nodes_Cypher_Relationships - Fatal编程技术网

Neo4j 否定多重关系

Neo4j 否定多重关系,neo4j,nodes,cypher,relationships,Neo4j,Nodes,Cypher,Relationships,假设一个节点与另一个节点有两种类型的关系,而与第三个节点只有一种类型的关系。例如,在手册()中,假设Node7还与Node4[导演]有额外的关系,因此道格拉斯同时出演并导演了《美国总统》 如何(在cypher中)只在所采取的关系类型上查找与node7相关的所有节点,而不显示此类也包含其他关系的已采取措施的相关节点?这一个如何 start n=node(3084) match n-[r]-m // might want to have direction?

假设一个节点与另一个节点有两种类型的关系,而与第三个节点只有一种类型的关系。例如,在手册()中,假设Node7还与Node4[导演]有额外的关系,因此道格拉斯同时出演并导演了《美国总统》

如何(在cypher中)只在所采取的关系类型上查找与node7相关的所有节点,而不显示此类也包含其他关系的已采取措施的相关节点?

这一个如何

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;

那么你是在问如何不显示重复的关系?太好了。这对那个案子有效。如果存在多个可能的关系,但我正在寻找确切的独占子集,该怎么办?遍历集合?没有办法在密码语法中做得更优雅,对吗?类似于比赛n-[r:acted_in |:Write]-m,但是为了强制执行排他性。是的,在比赛中没有好的方式来表达这一点。在中,您可以使用中的
自动迭代集合。假设您只得到了collr中带有
collect(type(r))的类型,您可以这样做:
其中collr中的“active”和collr中的“DIRECTED”