Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
06-12-2022 02:31 AM - last edited on 07-25-2022 09:11 AM by TrevorS
CALL gds.shortestPath.dijkstra.stream('entityGraph', {sourceNode: 4638405,targetNode: 998302}) YIELD path as path1
CALL gds.shortestPath.dijkstra.stream('entityGraph', {sourceNode: 4638405,targetNode: 2098491}) YIELD path as path2
WITH collect(path1) + collect(path2) as all RETURN all
Solved! Go to Solution.
06-12-2022 03:34 AM
The results of the second call get appended to the first’s results. If the second call has zero results, then nothing will be returned.
Use a call subquery to call them in a ‘union’ clause.
06-12-2022 03:34 AM
The results of the second call get appended to the first’s results. If the second call has zero results, then nothing will be returned.
Use a call subquery to call them in a ‘union’ clause.
06-12-2022 05:08 AM
I did this :
CALL {
CALL gds.shortestPath.dijkstra.stream('entityGraph', {sourceNode: 4638405,targetNode: 2098491}) YIELD path
UNION
CALL gds.shortestPath.dijkstra.stream('entityGraph', {sourceNode: 4638405,targetNode: 998302}) YIELD path
} return path
Now it says 'Unknown variable path@2'
06-12-2022 05:09 AM
Okay, I needed to add RETURN to end of each query.
06-23-2022 03:57 AM
I have a similar issue and so far I found no explanation why appending 'nothing' to 'something' returns nothing instead of something?
06-23-2022 04:40 AM
I guess you can consider it like a sql inner join when you have a collection of matches. The all have to return results and they are mixed together. The optional match is like a sql outer join; it will return 'null' for its result and the results are mixed together.
https://neo4j.com/docs/cypher-manual/current/clauses/optional-match/
All the sessions of the conference are now available online