Neo4J get node by ID

前端 未结 3 2095
囚心锁ツ
囚心锁ツ 2020-12-13 07:48

I am using neo4j for one of my project, there\'s a node which only has a single property as name, I want to get that node using ID, it already has a ID but when

相关标签:
3条回答
  • 2020-12-13 08:34

    Warning: The following answer is incorrect! START should only be used when accessing legacy indexes. It is disabled in Cypher 2.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)

    Keeping this answer to prevent anyone from making the same mistake.

    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
    
    0 讨论(0)
  • 2020-12-13 08:35
    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.

    0 讨论(0)
  • 2020-12-13 08:39

    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

    0 讨论(0)
提交回复
热议问题