1

I want to write a query to receive all parents till root node from any child node, ordered:

Here is the graph: enter image description here

I found some solutions, but result have some duplications or nodes weren't ordered. Thanks in advance.

Darii Petru
  • 142
  • 1
  • 12

1 Answers1

0

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
Darii Petru
  • 142
  • 1
  • 12