1

I have been using neo4jrb and have gotten by with using ActiveNode to do most of my object/relationship returns, but currently there are some queries I want to do with out having to do 2 ActiveNode calls and looping through both to get what I need. I am new to Cypher query language and trying to get over some hurdles.

The schema I am working with is I have 2 nodes of type A and B with relationships r1 and r2 in the form of (A)-[r1]->(B) and (A)-[r2]->(B). I want to be able in one Cypher query bring back all the node/relationship details for every B node in the DB.

ex. B1{B.id, A.id, [r1.id, r1.id, r1.id], [r2.id,r2.id,r2.id] },
B2{ B.id, A.id, [r1.id, r1.id, r1.id], [r2.id,r2.id,r2.id] } etc...

ndyr
  • 503
  • 4
  • 20

1 Answers1

1

I assume with the type B of the node, you mean the label

MATCH (b:B)-[r]-()
Return b,collect(r) as relationships 

ex. B1{B.id, A.id, [r1.id, r1.id, r1.id], [r2.id,r2.id,r2.id] }, If this is what you are looking for as result, I would do

MATCH (b:B)-[r:r]-()
MATCH (b:B)-[r1:r1]-()
RETURN b,collect(r.id),collect(r1.id)
Tomaž Bratanič
  • 6,319
  • 2
  • 18
  • 31