Join the free virtual developer conference on knowledge graphs and AI. This year's themes are: applications, AI engineering, data intelligence, graphs, and architecture.
I'm trying to make a query that would give me all the nodes of a certain label, associated with all of the nodes connected to them (node label, node property, relationship type).
For now I got this
MATCH (n:User)
MATCH (n)-[r]-(o)
RETURN n as node, collect(o), collect(labels(o)), collect(TYPE(r))
But this is not ideal, as I would have to to the mapping later, relying on the fact that the lists in column 2, 3, 4 are in the same order.
Perfect, now I think I understand more how to use WITH clause. Although I'm wondering something: I also need to return User nodes that have no relationships. That would happen with that statement, right ?
Thanks, but actually after testing I'm noticing I was not very clear, because with your first answer, if a user has several relationship, it returns one row per relationship, when what I'm trying to get in one row per user, with all its immediate connected nodes. Does that make sense ?
MATCH (n:User)
OPTIONAL MATCH (n)-[r]-(o)
WITH n as Node,{label:labels(o),type:type(r),properties: o} as Neighbor
WITH Node, collect(Neighbour) as Neighbor s
RETURN Node, Neighbors