[英]In neo4j how to return specific nodes or relationship with cypher?
You are given two arrays one for some labels and another for some relationships and you are asked to return the nodes and their relationships which are found only in the arrays you where given.您将获得两个数组,一个用于某些标签,另一个用于某些关系,并且要求您返回仅在您给定的数组中找到的节点及其关系。 I tried different approach to it but I couldn't get a better cipher to return the graph with respect to both arrays我尝试了不同的方法,但我无法获得更好的密码来返回关于两个数组的图形
MATCH (n)-[r]-(m) where n in ["username"] and r in ["knows"] return n,r
The code above, I know its completely wrong but it kinda shows the idea, share your thoughts 😁上面的代码,我知道它完全错误,但它有点显示了这个想法,分享你的想法😁
This should work:这应该有效:
MATCH (n)-[r]-(m)
WHERE ANY(l IN labels(n) WHERE l IN ['username','label2'])
AND type(r) IN ['knows','relType2']
RETURN n,r,m
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.