neo4j密码节点之间的多重关系 [英] neo4j cypher multi relationship between nodes
问题描述
例如:
a- [r]-> b,两个节点之间有多个r,每个r.userId是唯一的.
(例如:a- [r:R {userId:"user1"}]-> b,(a- [r:R {userId:"user2"}]-> b,
和a- [r]-> c
a-[r]->b, there are multi r between the two nodes, each r.userId is unique.
(eg: a-[r:R {userId:"user1"}]->b, (a-[r:R{userId:"user2"}]->b,
and the same for a-[r]->c
情况是a- [r]-> b有关系:r.userId = amdin,但是a- [r]-> c没有这种关系.
And the situation is a-[r]->b has a relationship: r.userId = amdin, but a-[r]->c doesn't have this relationship.
我怎么只能返回c.
我尝试创建密码:
"MATCH(a:SomeLabel)-[r:SomeR]->(any:SomeLabel)"
"WHERE ID(a)= 0 AND r.userId<> \" admin \"
返回任何";
"MATCH (a:SomeLabel)-[r:SomeR]->(any:SomeLabel) "
"WHERE id(a)=0 AND r.userId <> \"admin\" "
"RETURN any";
但是这也会返回b,因为a-> b具有其他关系:r.userId = xxxx
but this will also return b ,because a->b has other relationship: r.userId=xxxx
我如何编写密码以返回不灌输user.Id ="admin" ......
how can i write the cypher to return nodes not inculde user.Id="admin"......
如果您不清楚我的意思,请告诉我....在这种情况下我需要您的帮助.谢谢
我在下面画了一张名为sr的多重关系,但具有不同的属性(userId是唯一的), 并且我想查找与节点A相关但不包含sr {userId:admin}的所有节点,我在此处添加了一个红色下划线.因此,如图所示,节点B的关系为sr {userId:admin},所以我只想返回节点C,没有节点B
I draw a picture below, multi relationship named sr but with different properties (userId is unique), and i want to find all nodes that related to node A, but not contains sr {userId:admin}, i add a red underline there. So as in the picture, node B has the relationship sr {userId:admin}, so i only want to return node C, no node B
推荐答案
对于显示图形问题的简单表示,图形学家确实很有帮助,因为人们可以探索数据. 我已根据您的描述创建了一个: http://gist.neo4j.org/?94ef056e41153b116e4f
For showing simple representations of graph problems, graphgists are really helpful as people can explore the data. I've created one based on your description: http://gist.neo4j.org/?94ef056e41153b116e4f
对于您的问题,您可以收集每对节点之间关系中涉及的所有用户名,并根据以下内容进行过滤:
To your problem, you can collect all usernames involved in the relationships per pair of nodes and filter based on those:
MATCH (a { name:'A' })-[r:sr]->b
WITH a,b, collect(r.name) AS usernames
WHERE NOT 'admin' IN usernames
RETURN a, b
这篇关于neo4j密码节点之间的多重关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!