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!
In Neo4j, "Id" is a default internal property for both Nodes and Relationships. That means, when we create a new Node or Relationship, Neo4j Database Server will assign a number for internal usage. It is incremented automatically.
Syntax: Creating relationships The connections capture the semantic relationships and context of the nodes in the graph. When you create the relationship, it must have direction. You can query nodes for a relationship in either direction, but you must create the relationship with a direction.
When you want to return all nodes, relationships and paths found in a query, you can use the * symbol. This returns the two nodes, the relationship and the path used in the query.
Contents. The CREATE clause is used to create nodes and relationships.
Since ID isn't a property, it's returned using the ID function.
MATCH (n:Person) RETURN ID(n) LIMIT 5
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With