考虑到模式和关系,编写查询以获取 Abiodun 的二级朋友的问题

Issues writing a query that would fetch the second degree friends of Abiodun considering the pattern and the relationships

作为新手,我正在尝试编写一个密码查询,以考虑模式和关系来获取 Abiodun(node) 的二级好友。

初始代码

1) CREATE (abiodun:Person {name:"Abiodun"})
   RETURN abiodun

2) MATCH (abiodun:Person {name:"Abiodun"})
   CREATE (abiodun)-[like:LIKE]->(neo:Database {name:"Neo4j" }) 
   RETURN abiodun,like,neo

3)MATCH (abiodun:Person {name:"Abiodun"})
  FOREACH (name in ["Rajesh","Anna","Julia","Andrew"] |
  CREATE (abiodun)-[:FRIEND]->(:Person {name:name}))

4)MATCH (neo:Database {name:"Neo4j"})
  MATCH (anna:Person {name:"Anna"})
  CREATE (anna)-[:FRIEND]->(:Person:Expert {name:"Amanda"})-[:WORKED_WITH]->(neo) here

实际问题(到目前为止我做了什么

MATCH (abiodun) WHERE not ((abiodun)-[:FRIEND]->(myFriends)) 
RETURN n

我正在尝试编写一个只显示 Amanda 的查询

您可以使用从 Abiodun 到 Amanda 的固定长度关系。 关系中“*2”的意思是“给我一个阿比顿的朋友的朋友”。

MATCH (:Person {name: "Abiodun"}) - [:FRIEND*2] -> (p:Person)
RETURN p

可在此处找到详细信息:https://neo4j.com/docs/cypher-manual/current/clauses/match/#varlength-rels