I have two cypher queries that behave as expected. My graph simply consists of businesses connected by relationships.
# 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
I now want to combine aspects of these two queries into one. I want to find the shortest path between any two given nodes AND go 1-step out from the nodes in the returned path. I've tried the query below which doesn't work because p is returning a path and my second match statement is expecting a node.
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
How should I go about writing this type of query?