
GQLINSERT (p1:Paper {_id:'P1', title:'Efficient Graph Search', score:6, author:'Alex'}), (p2:Paper {_id:'P2', title:'Optimizing Queries', score:9, author:'Alex'}), (p3:Paper {_id:'P3', title:'Path Patterns', score:7, author:'Zack'}), (p1)-[:Cites {weight:2}]->(p2), (p2)-[:Cites {weight:1}]->(p3)
Gets the unique identifier _id of a graph element. element_id() is a synonym.
NOTEOn an edge
_iddisabled graph (see Node and Edge IDs) edges have no user-visible_id, soid(e)raises an error.
| Syntax | id(<elemVar>) or id(<elemVar>) | ||
| Arguments | Name | Type | Description |
<elemVar> | NODE, EDGE | Element variable reference | |
| Return Type | STRING | ||
GQLMATCH (n)-[e]->() RETURN id(n), id(e)
Result:
| id(n) | id(e) |
|---|---|
| P2 | 52ade0a7-0247-4e68-bafb-32d2b2fbaa8b |
| P1 | 22b49ab0-95ab-4591-bfd9-ff5cc5f9c633 |
Returns the system-internal numeric identifier (the _uuid) of a node or edge as a decimal string.
NOTEUnlike
id()which can error on edges in an edge_iddisabled graph,internal_id()always resolves. It's the function form of the built-in_uuidproperty and works on both edge_idenabled and disabled graphs.
| Syntax | internal_id(<elemVar>) | ||
| Arguments | Name | Type | Description |
<elemVar> | NODE, EDGE | Element variable reference. | |
| Return Type | STRING — the `_uuid` formatted as a decimal string. Returned as a string because the underlying value is a 64-bit unsigned integer that can exceed the signed-int range. | ||
GQLMATCH (n)-[e]->() RETURN internal_id(n), internal_id(e)
Result:
| internal_id(n) | internal_id(e) |
|---|---|
| 667260654663678695 | 2 |
| 667261754175306906 | 1 |
Equivalent property-form access:
GQLMATCH (n)-[e]->() RETURN n._uuid, e._uuid
Gets the labels of a graph element.
| Syntax | labels(<elemVar>) | ||
| Arguments | Name | Type | Description |
<elemVar> | NODE, EDGE | Element variable reference | |
| Return Type | LIST<STRING> | ||
GQLMATCH (n)-[e]->() RETURN labels(n), labels(e)
Result:
| labels(n) | labels(e) |
|---|---|
| ["Paper"] | ["Cites"] |
| ["Paper"] | ["Cites"] |
Gets the label of an edge. Equivalent to labels() for edges.
| Syntax | type(<edgeVar>) | ||
| Arguments | Name | Type | Description |
<edgeVar> | EDGE | Edge variable reference | |
| Return Type | STRING | ||
GQLMATCH ()-[e]->() RETURN type(e)
Result:
| type(e) |
|---|
| "Cites" |
| "Cites" |
Returns the property names of a node, edge, or key names of a record.
| Syntax | keys(<expr>) | ||
| Arguments | Name | Type | Description |
<expr> | NODE, EDGE, RECORD | The input expression | |
| Return Type | LIST<STRING> | ||
GQLMATCH (n:Paper) RETURN keys(n)
Result:
| keys(n) |
|---|
| ["score", "author", "title"] |
| ["score", "author", "title"] |
| ["score", "author", "title"] |
GQLLET myRecord = {x: 1, y: 3, z: 34} RETURN keys(myRecord)
Result:
| keys(myRecord) |
|---|
| ["x", "y", "z"] |
Returns the property values of a node, edge, or values of a record.
| Syntax | values(<expr>) | ||
| Arguments | Name | Type | Description |
<expr> | NODE, EDGE, RECORD | The input expression | |
| Return Type | LIST | ||
GQLLET myRecord = {x: 1, y: 3, z: 34} RETURN values(myRecord)
Result:
| values(myRecord) |
|---|
| [1, 3, 34] |
Returns the properties of a node or edge as a record.
| Syntax | properties(<elemVar>) | ||
| Arguments | Name | Type | Description |
<elemVar> | NODE, EDGE | Element variable reference | |
| Return Type | RECORD | ||
GQLMATCH (n:Paper) RETURN properties(n)
Result:
| properties(n) |
|---|
| {"score": 7, "author": "Zack", "title": "Path Patterns"} |
| {"score": 9, "author": "Alex", "title": "Optimizing Queries"} |
| {"score": 6, "author": "Alex", "title": "Efficient Graph Search"} |
Checks whether a property exists on a node or edge.
| Syntax | property_exists(<elemVar>, <propertyName>) | ||
| Arguments | Name | Type | Description |
<elemVar> | NODE, EDGE | Element variable reference | |
<propertyName> | STRING | The property name to check | |
| Return Type | BOOL | ||
GQLMATCH (n:Paper) RETURN n._id, property_exists(n, "score"), property_exists(n, "rating")
Result:
| n._id | property_exists(n, "score") | property_exists(n, "rating") |
|---|---|---|
| P1 | true | false |
| P2 | true | false |
| P3 | true | false |