简体   繁体   English

Neo4j Cypher Query 获取所有子节点,直到到达具有特定关系的节点

[英]Neo4j Cypher Query to get all sub nodes until reaching a node with a specific relationship

我正在尝试解析的图表

I am trying create a query in which starts with the blue nodes called "Analytical Units".我正在尝试创建一个查询,其中以名为“分析单位”的蓝色节点开头。 The query will get all sub-nodes unless it runs into a node which "overrides" the relationship by being directly attached to a different analytical unit.查询将获取所有子节点,除非它遇到一个节点,该节点通过直接附加到不同的分析单元来“覆盖”关系。 Any help would be appreciated!任何帮助,将不胜感激!

Does this query work for you?这个查询对你有用吗?

It should return each Blue node (that has a path to any Red nodes) and its "sub-nodes" (along each of those paths), ignoring paths in which any sub-node (except the first) has an incoming ANALYTICALLY_COMPOSED relationship:它应该返回每个Blue节点(具有到任何Red节点的路径)及其“子节点”(沿着每条路径),忽略任何子节点(第一个除外)具有传入ANALYTICALLY_COMPOSED关系的路径:

MATCH (a:Blue)-[:ANALYTICALLY_COMPOSED]->(b)
MATCH p=(b)-[rels*]-(:Red)
WITH a, NODES(p) AS subnodes
WHERE NONE(n IN subnodes[1..] WHERE ()-[:ANALYTICALLY_COMPOSED]->(n)) 
RETURN a, subnodes;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Neo4j Cypher Query:查找连接到一个节点且具有 3 个以上其他关系的所有节点 - Neo4j Cypher Query: Finding all nodes, that are connected to a node, that has more than 3 other relationships Neo4j Cypher 获取链表中的所有节点 - Neo4j Cypher get all nodes in a linked list Neo4j / Gremlin / Cypher:如何获取所有节点,直到我在类似地图的设置中达到一定距离(深度)? - Neo4j/Gremlin/Cypher: how to get all nodes until i reach a certain distance (depth) in a map-like setup? Neo4J (Cypher) 中图节点关系的最佳方法 - Best approach for graph nodes relationship in Neo4J (Cypher) Neo4j cypher计算并显示两个给定节点之间的所有关系 - Neo4j cypher to count and display all the relationship between two given nodes 如何在 Cypher Neo4j 中获取不包含(相关)具有特定属性的节点的所有节点 - How do I get all nodes that do not contain (relate) nodes with certain property in Cypher Neo4j NEO4J Cypher查询多个节点的START索引查询 - NEO4J Cypher query START index query with multiple nodes 如何在 Neo4J 中使用 Cypher 查询节点之间的扩展路径? - How to query extended path between nodes with Cypher in Neo4J? 无法过滤密码查询Neo4j上的节点 - Can't filter nodes on cypher query Neo4j Neo4j Cypher查询查找未连接的节点太慢 - Neo4j Cypher query to find nodes that are not connected too slow
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM