列表函数Graph
NebulaGraph 支持以下列表(List)函数。
函数 | 说明 |
---|---|
keys(expr) | 返回一个列表,包含字符串形式的点、边或映射的所有属性。 |
labels(vertex) | 返回点的 Tag 列表。 |
nodes(path) | 返回路径中所有点的列表。 |
range(start, end [, step]) | 返回[start,end] 范围内固定步长的列表,默认步长step 为 1。 |
relationships(path) | 返回路径中所有关系的列表。 |
reverse(list) | 返回将原列表逆序排列的新列表。 |
tail(list) | 返回不包含原列表第一个元素的新列表。 |
head(list) | 返回列表的第一个元素。 |
last(list) | 返回列表的最后一个元素。 |
coalesce(list) | 返回列表中第一个非空元素。 |
reduce() | 请参见 Graph。 |
Note
如果参数为NULL
,则输出结果是未定义的。
示例Graph
nebula> WITH [NULL, 4923, 'abc', 521, 487] AS ids \
RETURN reverse(ids), tail(ids), head(ids), last(ids), coalesce(ids);
+-----------------------------------+-------------------------+-----------+-----------+---------------+
| reverse(ids) | tail(ids) | head(ids) | last(ids) | coalesce(ids) |
+-----------------------------------+-------------------------+-----------+-----------+---------------+
| [487, 521, "abc", 4923, __NULL__] | [4923, "abc", 521, 487] | __NULL__ | 487 | 4923 |
+-----------------------------------+-------------------------+-----------+-----------+---------------+
nebula> MATCH (a:player)-[r]->() \
WHERE id(a) == "player100" \
RETURN labels(a), keys(r);
+------------+----------------------------+
| labels(a) | keys(r) |
+------------+----------------------------+
| ["player"] | ["degree"] |
| ["player"] | ["end_year", "start_year"] |
+------------+----------------------------+
nebula> MATCH p = (a:player)-[]->(b)-[]->(c:team) \
WHERE a.name == "Tim Duncan" AND c.name == "Spurs" \
RETURN nodes(p);
+-----------------------------------------------------------------------------------------------------------------------------------------------+
| nodes(p) |
+-----------------------------------------------------------------------------------------------------------------------------------------------+
| [("player100" :player{age: 42, name: "Tim Duncan"}), ("player101" :player{age: 36, name: "Tony Parker"}), ("team204" :team{name: "Spurs"})] |
| [("player100" :player{age: 42, name: "Tim Duncan"}), ("player125" :player{age: 41, name: "Manu Ginobili"}), ("team204" :team{name: "Spurs"})] |
+-----------------------------------------------------------------------------------------------------------------------------------------------+
nebula> MATCH p = (a:player)-[]->(b)-[]->(c:team) WHERE a.name == "Tim Duncan" AND c.name == "Spurs" RETURN relationships(p);
+-----------------------------------------------------------------------------------------------------------------------------+
| relationships(p) |
+-----------------------------------------------------------------------------------------------------------------------------+
| [[:follow "player100"->"player101" @0 {degree: 95}], [:serve "player101"->"team204" @0 {end_year: 2018, start_year: 1999}]] |
| [[:follow "player100"->"player125" @0 {degree: 95}], [:serve "player125"->"team204" @0 {end_year: 2018, start_year: 2002}]] |
+-----------------------------------------------------------------------------------------------------------------------------+
最后更新: November 24, 2021