简体   繁体   English

Cypher:获取具有特定关系的节点的所有关系

[英]Cypher: get all the relationships of node with a specific relationship

I'm trying to find all the relationships of the nodes which have one specific relationship.我试图找到具有一种特定关系的节点的所有关系。 People can be connected to events which in turn are connected to churches.人们可以与事件相关联,而这些事件又与教会相关联。 I'm interested in the people who are connected as witnesses to events (marriages) in the following manner:我对通过以下方式作为事件(婚姻)的见证人的人感兴趣:

(p:person)-[:ACTED_AS_BEKENDE]-(e:event)

What I'm struggling with is that when I write a simple MATCH statement with a WHERE clause (see below), I only get the events to which people were connected via this specific relationship.我正在努力解决的是,当我使用 WHERE 子句(见下文)编写一个简单的 MATCH 语句时,我只能得到人们通过这种特定关系连接到的事件。

MATCH (p:person)--(e:event)--(c:church)
WHERE (p:person)-[:ACTED_AS_BEKENDE]-(e:event)
RETURN distinct p.ID AS ID, p.Name AS NAME, labels(e) AS Event_name, e.Event_year AS year, labels(c) AS Church ORDER BY e.Event_year ASC

To reiterate: I need a query which first selects the people who are tied to events via the [:ACTED_AS_BEKENDE] edge and then retrieves all the events to which these people were tied.重申一下:我需要一个查询,它首先通过 [:ACTED_AS_BEKENDE] 边缘选择与事件相关的人,然后检索与这些人相关的所有事件。

Do you need something like this?你需要这样的东西吗?

MATCH (p:person)-[:ACTED_AS_BEKENDE]-(:event)
WITH p
MATCH (p)--(e:event)--(c:church)
RETURN distinct p.ID AS ID, p.Name AS NAME, labels(e) AS Event_name, e.Event_year AS year, labels(c) AS Church ORDER BY e.Event_year ASC

This will first find all persons that are ACTED_AS_BEKENDE, and for them it will fins the events and churches as you wanted这将首先找到所有 ACTED_AS_BEKENDE 的人,并为他们找到你想要的事件和教堂

暂无
暂无

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

相关问题 使用密码获取节点的所有关系 - get all relationships for a node with cypher Cypher:如果一个节点有多个关系,则批量删除特定关系的所有关系? - Cypher: Batch deleting all relationships for a specific relationship if there are more than one for a node? Neo4j cypher查询以获取与特定其他节点无关的所有节点 - Neo4j cypher query to get all nodes without a relationship to specific other node Neo4j Cypher Query 获取所有子节点,直到到达具有特定关系的节点 - Neo4j Cypher Query to get all sub nodes until reaching a node with a specific relationship 通过密码从节点获取所有传递关系 - get all transitive relationships from a node via cypher 获取连接到具有关系的特定节点的所有节点 - Get the all the nodes connected to a specific node with relationship 对于具有多个关系的节点,显示与cypher的所有传出关系 - Show all outgoing relationships with cypher for nodes that have more than 1 relationship Cypher(Neo4j)-查找所有关系,只要来自节点的一个关系满足条件即可,无论搜索路径如何? - Cypher (Neo4j) - Find all relationships as long as one relationship from node satisfies a condition regardless of search path? 如何使用cypher neo4j where子句获取节点的所有关系,而不仅仅是匹配的位置 - How to get all relationships of a node with cypher neo4j where clause, not only where matches Cypher通过关系获取根节点过滤器 - Cypher get root node filter by relationship
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM