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