How to get node's id with cypher request?

2019-04-19 09:26发布

I'm using neo4j and making executing this query:

MATCH (n:Person) RETURN n.name LIMIT 5

I'm getting the names but i need the ids too. Please help!

标签: neo4j cypher
3条回答
smile是对你的礼貌
2楼-- · 2019-04-19 09:52

Not sure how helpful or relevant this is, but when I'm using the NodeJS API the record objects returned from Cypher queries have an identity field on the same level as the properties object (e.g record.get(0).properties, record.get(0).identity). I'm assuming you aren't just doing plain Cypher queries and actually using a driver to send the queries - so you might not have to run another MATCH statement.

I'm aware that the OP is asking about Cypher specifically - but it might be helpful to other users that stumble upon this question.

查看更多
做个烂人
3楼-- · 2019-04-19 09:57

Or you can take a look on the Neo4j Cypher Refcard

You can get a short look to a lots of functions and patterns you can write.

And more about functions on The Neo4j Developer Manual - Chapter 3. Cypher - 3.4. Functions

查看更多
迷人小祖宗
4楼-- · 2019-04-19 10:01

Since ID isn't a property, it's returned using the ID function.

MATCH (n:Person) RETURN ID(n) LIMIT 5
查看更多
登录 后发表回答