Skip to content

Commit

Permalink
add annotation to some examples of FETCH clause (#2389)
Browse files Browse the repository at this point in the history
* add annotation to some examples of `FETCH` clause

as titled

* Update docs-2.0-zh/3.ngql-guide/7.general-query-statements/4.fetch.md

---------

Co-authored-by: abby.huang <[email protected]>
  • Loading branch information
knqiufan and abby-cyber authored Dec 11, 2023
1 parent 58a8ff7 commit ba401aa
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion docs-2.0-zh/3.ngql-guide/7.general-query-statements/4.fetch.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ YIELD [DISTINCT] <return_list> [AS <alias>];
`FETCH`语句中指定 Tag 获取对应点的属性值。

```ngql
# 获取 Tag 为 player,且 ID 为 player100 的点数据的属性值。
nebula> FETCH PROP ON player "player100" YIELD properties(vertex);
+-------------------------------+
| properties(VERTEX) |
Expand All @@ -42,6 +43,7 @@ nebula> FETCH PROP ON player "player100" YIELD properties(vertex);
使用`YIELD`子句指定返回的属性。

```ngql
# 获取 Tag 为 player,且 ID 为 player100 的点数据 name 的属性值。
nebula> FETCH PROP ON player "player100" \
YIELD properties(vertex).name AS name;
+--------------+
Expand All @@ -56,6 +58,7 @@ nebula> FETCH PROP ON player "player100" \
指定多个点 ID 获取多个点的属性值,点之间用英文逗号(,)分隔。

```ngql
# 获取 Tag 为 player,且 ID 为 player101,player102,player103 三个点数据的属性值。
nebula> FETCH PROP ON player "player101", "player102", "player103" YIELD properties(vertex);
+--------------------------------------+
| properties(VERTEX) |
Expand Down Expand Up @@ -89,6 +92,7 @@ nebula> FETCH PROP ON player, t1 "player100" YIELD vertex AS v;
用户可以在`FETCH`语句中组合多个 Tag 和多个点。

```ngql
# 获取 Tag 为 player 或 t1,且 ID 为 player100,player103 两个点数据的属性值。
nebula> FETCH PROP ON player, t1 "player100", "player103" YIELD vertex AS v;
+----------------------------------------------------------------------------+
| v |
Expand All @@ -103,6 +107,7 @@ nebula> FETCH PROP ON player, t1 "player100", "player103" YIELD vertex AS v;
`FETCH`语句中使用`*`获取当前图空间所有标签里,点的属性值。

```ngql
# 获取当前图空间所有标签里 ID 为 player100,player106,team200 的点数据属性值。
nebula> FETCH PROP ON * "player100", "player106", "team200" YIELD vertex AS v;
+----------------------------------------------------------------------------+
| v |
Expand Down Expand Up @@ -147,6 +152,7 @@ nebula> FETCH PROP ON serve "player100" -> "team204" YIELD properties(edge);
使用`YIELD`子句指定返回的属性。

```ngql
# 获取连接 player100 和 team204 的边 serve 的 start_year 属性值。
nebula> FETCH PROP ON serve "player100" -> "team204" \
YIELD properties(edge).start_year;
+-----------------------------+
Expand All @@ -161,6 +167,7 @@ nebula> FETCH PROP ON serve "player100" -> "team204" \
指定多个边模式 (`<src_vid> -> <dst_vid>[@<rank>]`) 获取多个边的属性值。模式之间用英文逗号(,)分隔。

```ngql
# 获取连接 player100 和 team204 的边,连接 player133 和 team202 的边 serve 的所有属性值。
nebula> FETCH PROP ON serve "player100" -> "team204", "player133" -> "team202" YIELD edge AS e;
+-----------------------------------------------------------------------+
| e |
Expand Down Expand Up @@ -204,7 +211,7 @@ nebula> FETCH PROP ON serve "player100" -> "team204"@1 YIELD edge AS e;
`FETCH`与原生 nGQL 结合使用是一种常见的方式,例如和`GO`一起。

```ngql
# 返回从点 player101 开始的 follow 边的 degree 值。
# 返回从点 player101 开始的 follow 边的 degree 值。src(edge) 获取边的起始点 ID,dst(edge) 获取边的目的点 ID。
nebula> GO FROM "player101" OVER follow \
YIELD src(edge) AS s, dst(edge) AS d \
| FETCH PROP ON follow $-.s -> $-.d \
Expand All @@ -221,6 +228,7 @@ nebula> GO FROM "player101" OVER follow \
用户也可以通过自定义变量构建类似的查询。

```ngql
# 返回从点 player101 开始的 follow 边的 degree 值。src(edge) 获取边的起始点 ID,dst(edge) 获取边的目的点 ID。
nebula> $var = GO FROM "player101" OVER follow \
YIELD src(edge) AS s, dst(edge) AS d; \
FETCH PROP ON follow $var.s -> $var.d \
Expand Down

0 comments on commit ba401aa

Please sign in to comment.