Neo4J get node by ID
MATCH (s)
WHERE ID(s) = 65110
RETURN s
The ID
function gets you the id of a node or relationship. This is different from any property called id
or ID
that you create.
START
should only be used when accessing legacy indexes. It is disabled in Cypher2.23.2 and up.Neo4j recommends using
WHERE ID(n) =
, and furthermore states that it will only require a single lookup (does not scan every node to find the matching ID)
WARNING |
---|
The answer below is incorrect. It is listed for reference only. See the updated answer above (quoted). The text below is kept for reference only |
You can use WHERE ID(s) = 65110
, but this will check the ID of every node in your database.
There is a more efficient way to do this:
START s=NODE(517) MATCH(s) RETURN s
you can say:
(n:User) where id(n) >=20 RETURN n
this will return all nodes of type User with node reference ID more than 20