简体   繁体   English

在 Neo4j 中如何返回特定节点或与密码的关系?

[英]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.

相关问题 Neo4j Cypher 排除缺少特定关系的节点 - Neo4j Cypher exclude nodes where a specific relationship is missing 查找没有特定关系的节点(Cypher / neo4j) - Finding nodes that do not have specific relationship (Cypher/neo4j) Neo4j 密码查询 - 如何返回路径节点但不包括具有相同特定属性的节点 - Neo4j cypher query - How to return path nodes but not include the nodes with identical specific properties Neo4j(密码):如何找到具有特定关系的所有节点? - Neo4j (cypher): How do I find all nodes with a specific relationship? Neo4j:如何删除与cypher的特定关系? - Neo4j: How do I delete a specific relationship with cypher? 如何使用 Neo4J 的 Cypher 查询返回关系类型? - How to return relationship type with Neo4J's Cypher queries? 将节点与具有常见关系的公共节点匹配-Neo4j Cypher - Match nodes with common nodes with a relationship - Neo4j Cypher Neo4j cypher查询以获取与特定其他节点无关的所有节点 - Neo4j cypher query to get all nodes without a relationship to specific other node Cypher / Neo4j:如何匹配与所有相关节点有关系的节点 - Cypher/Neo4j: How to match nodes that have relationship to all related nodes Neo4j Cypher Query 获取所有子节点,直到到达具有特定关系的节点 - Neo4j Cypher Query to get all sub nodes until reaching a node with a specific relationship
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM