Last Updated: February 25, 2016
·
1.383K
· cskardon

Getting Neo4J Relationships

So you have a collection of nodes and relationships in your Neo4j database, and want to get just the relationships?

(# indicates the node ID)

All relationships / edges
Cypher:
START n=node(#) MATCH n-[rel]-out RETURN rel

Gremlin:
g.v(#).bothE

Incoming relationships / edges
Cypher:
START n=node(#) MATCH n<-[rel]-out RETURN rel

Gremlin:
g.v(#).inE

Outgoing relationships / edges
Cypher:
START n=node(#) MATCH n-[rel]->out RETURN rel

Gremlin:
g.v(#).outE