简体   繁体   English

在neo4j cypher中检索确切的节点ID

[英]Retrieving exact node id in neo4j cypher

I'm using neo4j-jdbc 2.3.2 as my neo4j client for java. 我使用neo4j-jdbc 2.3.2作为java的neo4j客户端。 When I executed following cypher query 当我执行以下密码查询时
match(p:Person) where p.id_number='761201948V' return p.id;
it will return P2547228 as node id. 它将返回P2547228作为节点ID。 I feel like id is same as other properties of the node as I can use it inside where clauses. 我觉得id与节点的其他属性相同,因为我可以在where子句中使用它。

But here I'm expecting an integer which can use inside this query START p=node('node.id') return p; 但是在这里我期待一个可以在这个查询中使用的整数START p=node('node.id') return p; Is this id is an internal thing to neo4j db? 这个id是neo4j db的内部事吗? and is there a way to retrieve this id? 有没有办法检索这个ID?

From the following two cyphers what is most efficient one?(if both referring same node) 从以下两个密码中最有效的一个是什么?(如果两个都是相同的节点)

  1. START p=node('2547223') return p;
  2. match(p:Person) where p.id='P2547228' return p;

You have to use the ID(x) function for this. 您必须使用ID(x)函数。 Note, that ID(x) and x.id are a complete different thing. 注意, ID(x)x.id是完全不同的东西。 The former returns the internal node/relationship id managed by Neo4j itself. 前者返回由Neo4j本身管理的内部节点/关系id。 The latter gives the id property which is managed by the user and not by the database itself. 后者给出了id属性,它由用户管理,而不是由数据库本身管理。

Also note, that a node/relationship ID is always numeric. 另请注意,节点/关系ID始终为数字。

Using START is pretty much old school and shouldn't be used any more (except for accessing manual indexes): 使用START几乎是旧学校,不应再使用(除了访问手动索引):

start p=node(2547228) return p 

This one is a equivalent statement. 这是一个等同的陈述。 It is highly efficient since it just needs to do a simple seek operation on the node store: 它非常高效,因为它只需要在节点存储上执行简单的搜索操作:

match(p:Person) where id(p)=2547228 return p;

Looking for a property requires either a node label scan or a schema index lookup: 查找属性需要节点标签扫描或模式索引查找:

match(p:Person) where p.id=2547228 return p;

Just check out the query plans on your own by prefixing the statement with PROFILE . 只需在声明前加上PROFILE就可以自行查看查询计划。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM