Neo4j 密码查询到';展开';围绕节点路径

Neo4j 密码查询到';展开';围绕节点路径,neo4j,cypher,Neo4j,Cypher,我有两个密码查询,它们的行为与预期的一样。我的图表只是由通过关系连接的业务组成 # Finding the shortest path that exists between two given business nodes START a=node:Businesses('id: xxx'), b=node:Businesses('id: yyy') MATCH a, b, p= shortestPath((a)-[*..15]-(b)) RETURN p # Find all nodes

我有两个密码查询,它们的行为与预期的一样。我的图表只是由通过关系连接的业务组成

# Finding the shortest path that exists between two given business nodes
START a=node:Businesses('id: xxx'), b=node:Businesses('id: yyy')
MATCH a, b, p= shortestPath((a)-[*..15]-(b))
RETURN p

# Find all nodes connected 1-step out from a given business node
START a=node:Businesses('id: xxx')
MATCH (a)-[r:isRelated*]->(d)
RETURN distinct d,r
现在,我想将这两个查询的各个方面合并为一个查询。我想找到任意两个给定节点之间的最短路径,并从返回路径中的节点中走出一步。我尝试了下面的查询,但该查询不起作用,因为p返回一个路径,而我的第二个match语句需要一个节点

START a=node:Businesses('id: xxx'), b=node:Businesses('id: yyy')
MATCH a, b, p= allShortestPaths((a)-[*..15]-(b))
WITH p
MATCH (p)-[r:isRelated*1]->(d)
RETURN distinct p,d,r
我应该如何编写这种类型的查询?

如何:

START a=node:Businesses('id: xxx'), b=node:Businesses('id: yyy')
MATCH shortest=shortestPath((a)-[*..15]-(b)) 
WITH extract(n in nodes(shortest) | id(n)) as ids
MATCH pp=(x)-->(y)
WHERE id(x) in ids
RETURN pp
从最短路径收集所有节点ID,然后在第二部分进行筛选。我猜这个查询不是很有效,但是可以完成任务