I have a problem to connect the list of movies in the database in form of a sorted linked list (in a single cypher query).
Number of movie nodes: 25L
MATCH (movie:Movie)
WITH movie
ORDER BY movie.rating DESC
WITH collect(movie) as p
FOREACH (n IN nodes(p)| CREATE PREV_MOVIE-[:NextMovie]->(n) )
RETURN p
This will need reference to the previous node PREV_MOVIE
and the current node n
in the FOREACH
to create a relationship between the two. How to find the reference to the previous node PREV_MOVIE
here, or is there any other way to do the same?