I want to write a query to receive all parents till root node from any child node, ordered:
I found some solutions, but result have some duplications or nodes weren't ordered. Thanks in advance.
Solution that I came:
MATCH p=((s:storage)-[*]->(n:item {id: 1003}))
WITH nodes(p) AS nodes, length(p) AS distance
UNWIND nodes[0..size(nodes)] AS node
RETURN DISTINCT node.id, head(labels(node)) AS mainLabel