
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)
Returns the size of a path, list, or record.
| Syntax | cardinality(<expr>) | ||
| Arguments | Name | Type | Description |
<expr> | PATH, LIST, RECORD | The input expression | |
| Return Type | INT | ||
GQLMATCH p = ()->() LIMIT 1 RETURN cardinality(p)
Result: 3
GQLLET myList = [1, 2, null, 3] RETURN cardinality(myList)
Result: 4
GQLRETURN cardinality({x: 1, y: 3, z: 34})
Result: 3
Returns the type name of a value as a string.
| Syntax | typeof(<expr>) | ||
| Arguments | Name | Type | Description |
<expr> | Any | The input expression | |
| Return Type | STRING | ||
GQLMATCH (n:Paper) LIMIT 1 RETURN typeof(n.author)
Result:
| typeof |
|---|
| STRING |
GQLRETURN typeof(42), typeof("hello"), typeof([1,2,3])
Result:
| typeof | typeof | typeof |
|---|---|---|
| INTEGER | STRING | LIST |
Returns true if all arguments are different graph elements (compared by _id).
| Syntax | all_different(<elem1>, <elem2> [, ...]) | ||
| Arguments | Name | Type | Description |
<elem> | NODE, EDGE | Two or more element variable references | |
| Return Type | BOOL | ||
GQLMATCH (a), (b), (c) WHERE a._id = "P1" AND b._id = "P2" AND c._id = "P3" RETURN all_different(a, b, c)
Result: true