How to get node's id with cypher request?

混江龙づ霸主 提交于 2019-12-06 17:02:47

问题


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!


回答1:


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

MATCH (n:Person) RETURN ID(n) LIMIT 5



回答2:


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




回答3:


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.



来源:https://stackoverflow.com/questions/26203538/how-to-get-nodes-id-with-cypher-request

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!