示例图集
以下示例根据该图集运行:

cardinality()
返回列表中的元素总数。此函数适用于构造类型的值。
语法 | cardinality(<expr>) |
||
参数 | 名称 | 类型 | 描述 |
<expr> |
PATH ,LIST ,记录 |
输入表达式 | |
返回类型 | UINT |
MATCH p = ()->{1,3}()
RETURN p, cardinality(p)
结果:
p | cardinality(p) |
---|---|
(:Paper {_id: "P1", score: 6, title: "Efficient Graph Search", author: "Alex"})-[:Cites {weight: 2}]->(:Paper {_id: "P2", score: 9, title: "Optimizing Queries", author: "Alex"})-[:Cites {weight: 1]->(:Paper {_id: "P3", score: 7, title: "Path Patterns", author: "Zack"}) | 5 |
(:Paper {_id: "P1", score: 6, title: "Efficient Graph Search", author: "Alex"})-[:Cites {weight: 2]->(:Paper {_id: "P2", score: 9, title: "Optimizing Queries", author: "Alex"}) | 3 |
(:Paper {_id: "P2", score: 9, title: "Optimizing Queries", author: "Alex"})-[:Cites {weight: 1]->(:Paper {_id: "P3", score: 7, title: "Path Patterns", author: "Zack"}) | 3 |
LET myList = [1, 2, null, 3]
RETURN cardinality(myList)
结果:
cardinality(myList) |
---|
4 |
LET rec = RECORD{no: 1, value: "tennis"}
RETURN cardinality(rec)
结果:
cardinality(rec) |
---|
2 |
cast()
指定数据转换。
语法 | cast(<value> AS <target>) |
||
参数 | 名称 | 类型 | 描述 |
<value> |
/ | 值表达式 | |
<target> |
/ | 任意值类型 | |
Return Type | 如<target> 指定 |
RETURN cast(1 AS String)
结果:
cast(1 AS String) |
---|
1 |
element_id()
获取图元素的唯一标识符_uuid
。
语法 | element_id(<elemVar>) |
||
参数 | 名称 | 类型 | 描述 |
<elemVar> |
NODE ,EDGE |
元素变量引用 | |
返回类型 | UINT64 |
MATCH (n)-[e]->()
RETURN element_id(n), element_id(e)
结果:
element_id(n) | element_id(e) |
---|---|
8718971077612535810 | 1 |
8791028671650463745 | 2 |
labels()
获取图元素的标签。
语法 | labels(<elemVar>) |
||
参数 | 名称 | 类型 | 描述 |
<elemVar> |
NODE , EDGE |
元素变量引用 | |
返回类型 | STRING |
MATCH (n)-[e]->()
RETURN labels(n), labels(e)
结果:
labels(n) | labels(e) |
---|---|
Paper | Cites |
Paper | Cites |