neo4j: how to return nodes' content with node name?

537 Views Asked by At

I select a path and want to return distinct nodes from that path with labels:

match path = ...
unwind(nodes(path)) as node
return distinct node { .*, type: labels(node)}

As a result I get

[{node={a:1, b:2, type=[t]}}, {node={a:3, b:4 type=[x]}}]

i want to get rid of the node text and receive:

[{a:1, b:2, type=[t]}, {a:3, b:4 type=[x]}]

how can i achieve that?

neo4j version 3.3.1: docker run --rm -p 7474:7474 --env=NEO4J_AUTH=none neo4j:3.3.1

1

There are 1 best solutions below

3
On

(Update:) the solution in your question seems to be working fine.

match (node)
return distinct node { .*, type: labels(node) }
limit 1

Originally, I was suggesting to use the properties function, but that overcomplicates things unnecessarily:

match (node)
with node, properties(node) as props
return distinct props { .*, type: labels(node) }
limit 1