
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.
| Syntax | element_id(<elemVar>) or id(<elemVar>) | ||
| Arguments | Name | Type | Description |
<elemVar> | NODE, EDGE | Element variable reference | |
| Return Type | STRING | ||
GQLMATCH (n)-[e]->() RETURN element_id(n), id(e)
Result:
| element_id | id |
|---|---|
| P2 | e:2 |
| P1 | e:1 |
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 | labels |
|---|---|
| ["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 |
|---|
| 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 |
|---|
| ["score", "author", "title"] |
| ["score", "author", "title"] |
| ["score", "author", "title"] |
GQLLET myRecord = {x: 1, y: 3, z: 34} RETURN keys(myRecord)
Result:
| keys |
|---|
| ["x", "y", "z"] |
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 |
|---|
| {"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 | property_exists |
|---|---|---|
| P1 | true | false |
| P2 | true | false |
| P3 | true | false |