Neo4J – How to retrieve START_ID, END_ID and ID from a relationship?

If I query a relationship in my database like below

MATCH (n)-[t]-[n] RETURN t

I get the following output:

{
  "identity": 423006861,
  "start": 89091471,
  "end": 278664,
  "type": "RELATION",
  "properties": {
     "value": 7.0
  }
}

How can I access the identity, start, end and type values?

[...] RETURN t.start just gives me null which is clearly not right…

I have the feeling that only the properties part can be accessed. Is this true? What am I doing wrong?

>Solution :

The following functions are available on relationships :

  • startNode()
  • endNode()
  • id()

So,

MATCH (n)-[t]-[n]
RETURN
id(startNode(t)) AS startNodeId,
id(endNode(t)) AS endNodeId,
id(t) AS relationshipId

Leave a Reply