diff --git a/docs-2.0/1.introduction/3.nebula-graph-architecture/3.graph-service.md b/docs-2.0/1.introduction/3.nebula-graph-architecture/3.graph-service.md index eeb4187915d..fc901892b11 100644 --- a/docs-2.0/1.introduction/3.nebula-graph-architecture/3.graph-service.md +++ b/docs-2.0/1.introduction/3.nebula-graph-architecture/3.graph-service.md @@ -20,7 +20,7 @@ Graph 服务主要负责处理查询请求,包括解析查询语句、校验 Parser 模块收到请求后,通过 Flex(词法分析工具)和 Bison(语法分析工具)生成的词法语法解析器,将语句转换为抽象语法树(AST),在语法解析阶段会拦截不符合语法规则的语句。 -例如`GO FROM "Tim" OVER like WHERE like.likeness > 8.0 YIELD like._dst`语句转换的 AST 如下。 +例如`GO FROM "Tim" OVER like WHERE properties(edge).likeness > 8.0 YIELD dst(edge)`语句转换的 AST 如下。 ![AST](https://docs-cdn.nebula-graph.com.cn/docs-2.0/1.introduction/2.nebula-graph-architecture/parser-ast-tree.png) @@ -38,7 +38,7 @@ Validator 模块对生成的 AST 进行语义校验,主要包括: 校验引用的变量是否存在或者引用的属性是否属于变量。 - 例如语句`$var = GO FROM "Tim" OVER like YIELD like._dst AS ID; GO FROM $var.ID OVER serve YIELD serve._dst`,Validator 模块首先会检查变量 `var` 是否定义,其次再检查属性 `ID` 是否属于变量 `var`。 + 例如语句`$var = GO FROM "Tim" OVER like YIELD dst(edge) AS ID; GO FROM $var.ID OVER serve YIELD dst(edge)`,Validator 模块首先会检查变量 `var` 是否定义,其次再检查属性 `ID` 是否属于变量 `var`。 - 校验类型推断 @@ -50,13 +50,13 @@ Validator 模块对生成的 AST 进行语义校验,主要包括: 查询语句中包含 `*` 时,校验子句时需要将 `*` 涉及的Schema都进行校验。 - 例如语句`GO FROM "Tim" OVER * YIELD like._dst, like.likeness, serve._dst`,校验`OVER`子句时需要校验所有的 Edge type,如果 Edge type 包含 `like`和`serve`,该语句会展开为`GO FROM "Tim" OVER like,serve YIELD like._dst, like.likeness, serve._dst`。 + 例如语句`GO FROM "Tim" OVER * YIELD dst(edge), properties(edge).likeness, dst(edge)`,校验`OVER`子句时需要校验所有的 Edge type,如果 Edge type 包含 `like`和`serve`,该语句会展开为`GO FROM "Tim" OVER like,serve YIELD dst(edge), properties(edge).likeness, dst(edge)`。 - 校验输入输出 校验管道符(|)前后的一致性。 - 例如语句`GO FROM "Tim" OVER like YIELD like._dst AS ID | GO FROM $-.ID OVER serve YIELD serve._dst`,Validator 模块会校验 `$-.ID` 在管道符左侧是否已经定义。 + 例如语句`GO FROM "Tim" OVER like YIELD dst(edge) AS ID | GO FROM $-.ID OVER serve YIELD dst(edge)`,Validator 模块会校验 `$-.ID` 在管道符左侧是否已经定义。 校验完成后,Validator 模块还会生成一个默认可执行,但是未进行优化的执行计划,存储在目录 `src/planner` 内。 diff --git a/docs-2.0/14.client/4.nebula-java-client.md b/docs-2.0/14.client/4.nebula-java-client.md index 7ae1dcc909c..a68f665e8e3 100644 --- a/docs-2.0/14.client/4.nebula-java-client.md +++ b/docs-2.0/14.client/4.nebula-java-client.md @@ -101,7 +101,7 @@ try { ResultSet resp = session.execute(insertEdges); // query - String query = "GO FROM \"Bob\" OVER like " + "YIELD $$.person.name, $$.person.age, like.likeness"; + String query = "GO FROM \"Bob\" OVER like " + "YIELD properties($$).name, properties($$).age, properties(edge).likeness"; ResultSet resp = session.execute(query); printResult(resp); }finally { diff --git a/docs-2.0/2.quick-start/4.nebula-graph-crud.md b/docs-2.0/2.quick-start/4.nebula-graph-crud.md index 2ad1e4485f0..1893c094bcd 100644 --- a/docs-2.0/2.quick-start/4.nebula-graph-crud.md +++ b/docs-2.0/2.quick-start/4.nebula-graph-crud.md @@ -269,9 +269,12 @@ Execution succeeded (time spent 5858/6870 us) ```ngql GO [[ TO] STEPS ] FROM - OVER [REVERSELY] [BIDIRECT] - [WHERE [AND | OR expression ...])] - YIELD [DISTINCT] ; + OVER [{REVERSELY | BIDIRECT}] + [ WHERE  ] + [YIELD [DISTINCT] ] + [| GROUP BY {col_name | expr | position} YIELD ] + [| ORDER BY [{ASC | DESC}]] + [| LIMIT [,] ]; ``` - `FETCH` @@ -279,24 +282,24 @@ Execution succeeded (time spent 5858/6870 us) - 查询Tag属性 ```ngql - FETCH PROP ON { | | *} - [YIELD [DISTINCT] ]; + FETCH PROP ON {[, tag_name ...] | *} + [, vid ...] + [YIELD [AS ]]; ``` - 查询边属性 ```ngql - FETCH PROP ON -> [@] - [, -> ...] - [YIELD [DISTINCT] ]; + FETCH PROP ON -> [@] [, -> ...] + [YIELD ]; ``` - `LOOKUP` ```ngql - LOOKUP ON { | } - WHERE [AND expression ...])] - [YIELD ]; + LOOKUP ON { | } + [WHERE [AND ...]] + [YIELD [AS ]]; ``` - `MATCH` @@ -324,14 +327,15 @@ Execution succeeded (time spent 5858/6870 us) - 从VID为`player100`的球员开始,沿着边`follow`查找年龄大于或等于35岁的球员,并返回他们的姓名和年龄,同时重命名对应的列。 ```ngql - nebula> GO FROM "player100" OVER follow WHERE $$.player.age >= 35 \ - YIELD $$.player.name AS Teammate, $$.player.age AS Age; - +---------------+-----+ - | Teammate | Age | - +---------------+-----+ - | "Tony Parker" | 36 | - +---------------+-----+ - Got 1 rows (time spent 8206/9335 us) + nebula> GO FROM "player100" OVER follow WHERE properties($$).age >= 35 \ + YIELD properties($$).name AS Teammate, properties($$).age AS Age; + +-----------------+-----+ + | Teammate | Age | + +-----------------+-----+ + | "Tony Parker" | 36 | + +-----------------+-----+ + | "Manu Ginobili" | 41 | + +-----------------+-----+ ``` |子句/符号|说明| @@ -345,15 +349,18 @@ Execution succeeded (time spent 5858/6870 us) - 使用管道符 ```ngql - nebula> GO FROM "player100" OVER follow YIELD follow._dst AS id | \ - GO FROM $-.id OVER serve YIELD $$.team.name AS Team, \ - $^.player.name AS Player; - +-----------+---------------+ - | Team | Player | - +-----------+---------------+ - | "Nuggets" | "Tony Parker" | - +-----------+---------------+ - Got 1 rows (time spent 5055/8203 us) + nebula> GO FROM "player100" OVER follow YIELD dst(edge) AS id | \ + GO FROM $-.id OVER serve YIELD properties($$).name AS Team, \ + properties($^).name AS Player; + +-----------+-----------------+ + | Team | Player | + +-----------+-----------------+ + | "Spurs" | "Tony Parker" | + +-----------+-----------------+ + | "Hornets" | "Tony Parker" | + +-----------+-----------------+ + | "Spurs" | "Manu Ginobili" | + +-----------+-----------------+ ``` |子句/符号|说明| @@ -369,15 +376,18 @@ Execution succeeded (time spent 5858/6870 us) 当复合语句作为一个整体提交给服务器时,其中的临时变量会在语句结束时被释放。 ```ngql - nebula> $var = GO FROM "player100" OVER follow YIELD follow._dst AS id; \ - GO FROM $var.id OVER serve YIELD $$.team.name AS Team, \ - $^.player.name AS Player; - +---------+-------------+ - | Team | Player | - +---------+-------------+ - | Nuggets | Tony Parker | - +---------+-------------+ - Got 1 rows (time spent 3103/3711 us) + nebula> $var = GO FROM "player100" OVER follow YIELD dst(edge) AS id; \ + GO FROM $var.id OVER serve YIELD properties($$).name AS Team, \ + properties($^).name AS Player; + +-----------+-----------------+ + | Team | Player | + +-----------+-----------------+ + | "Spurs" | "Tony Parker" | + +-----------+-----------------+ + | "Hornets" | "Tony Parker" | + +-----------+-----------------+ + | "Spurs" | "Manu Ginobili" | + +-----------+-----------------+ ``` ### `FETCH`语句示例 @@ -391,7 +401,6 @@ nebula> FETCH PROP ON player "player100"; +----------------------------------------------------+ | ("player100" :player{age: 42, name: "Tim Duncan"}) | +----------------------------------------------------+ -Got 1 rows (time spent 2006/2406 us) ``` !!! Note diff --git a/docs-2.0/3.ngql-guide/1.nGQL-overview/1.overview.md b/docs-2.0/3.ngql-guide/1.nGQL-overview/1.overview.md index 8d612f0ac2f..5316a4604a1 100644 --- a/docs-2.0/3.ngql-guide/1.nGQL-overview/1.overview.md +++ b/docs-2.0/3.ngql-guide/1.nGQL-overview/1.overview.md @@ -156,18 +156,18 @@ Feature: Comparison of where clause When profiling query: """ GO FROM "player100" OVER follow - WHERE follow.degree IN [v IN [95,99] WHERE v > 0] - YIELD follow._dst, follow.degree + WHERE properties(edge).degree IN [v IN [95,99] WHERE v > 0] + YIELD dst(edge), properties(edge).degree """ Then the result should be, in any order: | follow._dst | follow.degree | | "player101" | 95 | | "player125" | 95 | And the execution plan should be: - | id | name | dependencies | operator info | - | 0 | Project | 1 | | - | 1 | GetNeighbors | 2 | {"filter": "(follow.degree IN [v IN [95,99] WHERE (v>0)])"} | - | 2 | Start | | | + | id | name | dependencies | operator info | + | 0 | Project | 1 | | + | 1 | GetNeighbors | 2 | {"filter": "(properties(edge).degree IN [v IN [95,99] WHERE (v>0)])"} | + | 2 | Start | | | ``` 示例中的关键字说明如下。 diff --git a/docs-2.0/3.ngql-guide/1.nGQL-overview/ngql-style-guide.md b/docs-2.0/3.ngql-guide/1.nGQL-overview/ngql-style-guide.md index 5e87ce633da..b55e7e1ebf4 100644 --- a/docs-2.0/3.ngql-guide/1.nGQL-overview/ngql-style-guide.md +++ b/docs-2.0/3.ngql-guide/1.nGQL-overview/ngql-style-guide.md @@ -13,7 +13,7 @@ nGQL没有严格的构建格式要求,但根据恰当而统一的风格创建n 不推荐: ```ngql - GO FROM "player100" OVER follow REVERSELY YIELD follow._dst AS id; + GO FROM "player100" OVER follow REVERSELY YIELD src(edge) AS id; ``` 推荐: @@ -21,7 +21,7 @@ nGQL没有严格的构建格式要求,但根据恰当而统一的风格创建n ```ngql GO FROM "player100" \ OVER follow REVERSELY \ - YIELD follow._dst AS id; + YIELD src(edge) AS id; ``` 2. 换行写复合语句中的不同语句。 @@ -29,8 +29,8 @@ nGQL没有严格的构建格式要求,但根据恰当而统一的风格创建n 不推荐: ```ngql - GO FROM "player100" OVER follow REVERSELY YIELD follow._dst AS id | GO FROM $-.id \ - OVER serve WHERE $^.player.age > 20 YIELD $^.player.name AS FriendOf, $$.team.name AS Team; + GO FROM "player100" OVER follow REVERSELY YIELD src(edge) AS id | GO FROM $-.id \ + OVER serve WHERE properties($^).age > 20 YIELD properties($^).name AS FriendOf, properties($$).name AS Team; ``` 推荐: @@ -38,10 +38,10 @@ nGQL没有严格的构建格式要求,但根据恰当而统一的风格创建n ```ngql GO FROM "player100" \ OVER follow REVERSELY \ - YIELD follow._dst AS id | \ + YIELD src(edge) AS id | \ GO FROM $-.id OVER serve \ - WHERE $^.player.age > 20 \ - YIELD $^.player.name AS FriendOf, $$.team.name AS Team; + WHERE properties($^).age > 20 \ + YIELD properties($^).name AS FriendOf, properties($$).name AS Team; ``` 3. 子句长度超过80个字符时,在合适的位置换行。 @@ -218,10 +218,10 @@ nGQL没有严格的构建格式要求,但根据恰当而统一的风格创建n ```ngql GO FROM "player100" \ OVER follow \ - YIELD follow._dst AS id; | \ + YIELD dst(edge) AS id; | \ GO FROM $-.id \ OVER serve \ - YIELD $$.team.name AS Team, $^.player.name AS Player; + YIELD properties($$).name AS Team, properties($^).name AS Player; ``` 支持: @@ -229,10 +229,10 @@ nGQL没有严格的构建格式要求,但根据恰当而统一的风格创建n ```ngql GO FROM "player100" \ OVER follow \ - YIELD follow._dst AS id | \ + YIELD dst(edge) AS id | \ GO FROM $-.id \ OVER serve \ - YIELD $$.team.name AS Team, $^.player.name AS Player; + YIELD properties($$).name AS Team, properties($^).name AS Player; ``` 3. 在包含自定义变量的复合语句中,用英文分号结束定义变量的语句。不按规则加分号或使用管道符结束该语句会导致执行失败。 @@ -242,10 +242,10 @@ nGQL没有严格的构建格式要求,但根据恰当而统一的风格创建n ```ngql $var = GO FROM "player100" \ OVER follow \ - YIELD follow._dst AS id \ + YIELD dst(edge) AS id \ GO FROM $var.id \ OVER serve \ - YIELD $$.team.name AS Team, $^.player.name AS Player; + YIELD properties($$).name AS Team, properties($^).name AS Player; ``` 也不支持: @@ -253,10 +253,10 @@ nGQL没有严格的构建格式要求,但根据恰当而统一的风格创建n ```ngql $var = GO FROM "player100" \ OVER follow \ - YIELD follow._dst AS id | \ + YIELD dst(edge) AS id | \ GO FROM $var.id \ OVER serve \ - YIELD $$.team.name AS Team, $^.player.name AS Player; + YIELD properties($$).name AS Team, properties($^).name AS Player; ``` 支持: @@ -264,8 +264,8 @@ nGQL没有严格的构建格式要求,但根据恰当而统一的风格创建n ```ngql $var = GO FROM "player100" \ OVER follow \ - YIELD follow._dst AS id; \ + YIELD dst(edge) AS id; \ GO FROM $var.id \ OVER serve \ - YIELD $$.team.name AS Team, $^.player.name AS Player; + YIELD properties($$).name AS Team, properties($^).name AS Player; ``` diff --git a/docs-2.0/3.ngql-guide/12.vertex-statements/4.delete-vertex.md b/docs-2.0/3.ngql-guide/12.vertex-statements/4.delete-vertex.md index c96df6bb253..647b0e53f63 100644 --- a/docs-2.0/3.ngql-guide/12.vertex-statements/4.delete-vertex.md +++ b/docs-2.0/3.ngql-guide/12.vertex-statements/4.delete-vertex.md @@ -24,7 +24,7 @@ nebula> DELETE VERTEX "team1"; ```ngql # 结合管道符,删除符合条件的点。 -nebula> GO FROM "player100" OVER serve WHERE serve.start_year == "2021" YIELD serve._dst AS id | DELETE VERTEX $-.id; +nebula> GO FROM "player100" OVER serve WHERE properties(edge).start_year == "2021" YIELD dst(edge) AS id | DELETE VERTEX $-.id; ``` ## 删除过程与删除邻边 diff --git a/docs-2.0/3.ngql-guide/13.edge-statements/2.update-edge.md b/docs-2.0/3.ngql-guide/13.edge-statements/2.update-edge.md index 93e161db07e..b874ae830de 100644 --- a/docs-2.0/3.ngql-guide/13.edge-statements/2.update-edge.md +++ b/docs-2.0/3.ngql-guide/13.edge-statements/2.update-edge.md @@ -30,7 +30,7 @@ SET // 用GO语句查看边的属性值。 nebula> GO FROM "player100" \ OVER serve \ - YIELD serve.start_year, serve.end_year; + YIELD properties(edge).start_year, properties(edge).end_year; +------------------+----------------+ | serve.start_year | serve.end_year | +------------------+----------------+ diff --git a/docs-2.0/3.ngql-guide/13.edge-statements/3.upsert-edge.md b/docs-2.0/3.ngql-guide/13.edge-statements/3.upsert-edge.md index 78fd063e82f..3d6ca6e7428 100644 --- a/docs-2.0/3.ngql-guide/13.edge-statements/3.upsert-edge.md +++ b/docs-2.0/3.ngql-guide/13.edge-statements/3.upsert-edge.md @@ -57,7 +57,7 @@ SET // 查看如下三个点是否有serve类型的出边,结果“Empty set”表示没有serve类型的出边。 nebula> GO FROM "player666", "player667", "player668" \ OVER serve \ - YIELD serve.start_year, serve.end_year; + YIELD properties(edge).start_year, properties(edge).end_year; Empty set nebula> UPSERT EDGE on serve \ diff --git a/docs-2.0/3.ngql-guide/13.edge-statements/4.delete-edge.md b/docs-2.0/3.ngql-guide/13.edge-statements/4.delete-edge.md index fcab621202c..15106d6150b 100644 --- a/docs-2.0/3.ngql-guide/13.edge-statements/4.delete-edge.md +++ b/docs-2.0/3.ngql-guide/13.edge-statements/4.delete-edge.md @@ -22,7 +22,7 @@ nebula> DELETE EDGE serve "player100" -> "team204"@0; ```ngql # 结合管道符,删除符合条件的边。 nebula> GO FROM "player100" OVER follow \ - WHERE follow._dst == "team204" \ - YIELD follow._src AS src, follow._dst AS dst, follow._rank AS rank \ + WHERE dst(edge) == "team204" \ + YIELD src(edge) AS src, dst(edge) AS dst, rank(edge) AS rank \ | DELETE EDGE follow $-.src->$-.dst @ $-.rank; ``` diff --git a/docs-2.0/3.ngql-guide/3.data-types/6.list.md b/docs-2.0/3.ngql-guide/3.data-types/6.list.md index 489bf92ba5a..3d72c35c7be 100644 --- a/docs-2.0/3.ngql-guide/3.data-types/6.list.md +++ b/docs-2.0/3.ngql-guide/3.data-types/6.list.md @@ -180,8 +180,8 @@ nebula> RETURN size([1,2,3]); +---------------+ # 将列表[92,90]中的元素做运算,然后在where子句中进行条件判断。 -nebula> GO FROM "player100" OVER follow WHERE follow.degree NOT IN [x IN [92, 90] | x + $$.player.age] \ - YIELD follow._dst AS id, follow.degree AS degree; +nebula> GO FROM "player100" OVER follow WHERE properties(edge).degree NOT IN [x IN [92, 90] | x + $$.player.age] \ + YIELD dst(edge) AS id, properties(edge).degree AS degree; +-------------+--------+ | id | degree | +-------------+--------+ diff --git a/docs-2.0/3.ngql-guide/4.variable-and-composite-queries/1.composite-queries.md b/docs-2.0/3.ngql-guide/4.variable-and-composite-queries/1.composite-queries.md index eefeadaa195..6ad092db240 100644 --- a/docs-2.0/3.ngql-guide/4.variable-and-composite-queries/1.composite-queries.md +++ b/docs-2.0/3.ngql-guide/4.variable-and-composite-queries/1.composite-queries.md @@ -59,12 +59,16 @@ Nebula Graph支持三种方式进行复合查询(或子查询): ```ngql # 管道符连接多个查询。 - nebula> GO FROM "player100" OVER follow YIELD follow._dst AS id | \ - GO FROM $-.id OVER serve YIELD $$.team.name AS Team, \ - $^.player.name AS Player; - +---------+-------------+ - | Team | Player | - +---------+-------------+ - | Nuggets | Tony Parker | - +---------+-------------+ + nebula> GO FROM "player100" OVER follow YIELD dst(edge) AS id | \ + GO FROM $-.id OVER serve YIELD properties($$).name AS Team, \ + properties($^).name AS Player; + +-----------+-----------------+ + | Team | Player | + +-----------+-----------------+ + | "Spurs" | "Tony Parker" | + +-----------+-----------------+ + | "Hornets" | "Tony Parker" | + +-----------+-----------------+ + | "Spurs" | "Manu Ginobili" | + +-----------+-----------------+ ``` diff --git a/docs-2.0/3.ngql-guide/4.variable-and-composite-queries/2.user-defined-variables.md b/docs-2.0/3.ngql-guide/4.variable-and-composite-queries/2.user-defined-variables.md index 0f005f75250..34d59faf6cd 100644 --- a/docs-2.0/3.ngql-guide/4.variable-and-composite-queries/2.user-defined-variables.md +++ b/docs-2.0/3.ngql-guide/4.variable-and-composite-queries/2.user-defined-variables.md @@ -32,12 +32,16 @@ nGQL扩展的自定义变量可以表示为`$var_name`,`var_name`由字母、 ## 示例 ```ngql -nebula> $var = GO FROM "player100" OVER follow YIELD follow._dst AS id; \ - GO FROM $var.id OVER serve YIELD $$.team.name AS Team, \ - $^.player.name AS Player; -+---------+-------------+ -| Team | Player | -+---------+-------------+ -| Nuggets | Tony Parker | -+---------+-------------+ +nebula> $var = GO FROM "player100" OVER follow YIELD dst(edge) AS id; \ + GO FROM $var.id OVER serve YIELD properties($$).name AS Team, \ + properties($^).name AS Player; ++-----------+-----------------+ +| Team | Player | ++-----------+-----------------+ +| "Spurs" | "Tony Parker" | ++-----------+-----------------+ +| "Hornets" | "Tony Parker" | ++-----------+-----------------+ +| "Spurs" | "Manu Ginobili" | ++-----------+-----------------+ ``` diff --git a/docs-2.0/3.ngql-guide/4.variable-and-composite-queries/3.property-reference.md b/docs-2.0/3.ngql-guide/4.variable-and-composite-queries/3.property-reference.md index 33a82c0bca7..815b7983ca0 100644 --- a/docs-2.0/3.ngql-guide/4.variable-and-composite-queries/3.property-reference.md +++ b/docs-2.0/3.ngql-guide/4.variable-and-composite-queries/3.property-reference.md @@ -60,7 +60,7 @@ $$.. ```ngql # 返回起始点的Tag player的name属性值和目的点的Tag player的age属性值。 -nebula> GO FROM "player100" OVER follow YIELD $^.player.name AS startName, $$.player.age AS endAge; +nebula> GO FROM "player100" OVER follow YIELD properties($^).name AS startName, properties($$).age AS endAge; +--------------+--------+ | startName | endAge | +--------------+--------+ @@ -70,7 +70,7 @@ nebula> GO FROM "player100" OVER follow YIELD $^.player.name AS startName, $$.pl +--------------+--------+ # 返回Edge type follow的degree属性值。 -nebula> GO FROM "player100" OVER follow YIELD follow.degree; +nebula> GO FROM "player100" OVER follow YIELD properties(edge).degree; +---------------+ | follow.degree | +---------------+ @@ -80,12 +80,12 @@ nebula> GO FROM "player100" OVER follow YIELD follow.degree; +---------------+ # 返回EdgeType 是 follow 的起始点 VID、目的点 VID、EdgeType 编码(正数为正向边,负数为逆向边),和边的 rank 值。 -nebula> GO FROM "player100" OVER follow YIELD follow._src, follow._dst, follow._type, follow._rank; -+-------------+-------------+--------------+--------------+ -| follow._src | follow._dst | follow._type | follow._rank | -+-------------+-------------+--------------+--------------+ -| "player100" | "player101" | 136 | 0 | -+-------------+-------------+--------------+--------------+ -| "player100" | "player102" | 136 | 0 | -+-------------+-------------+--------------+--------------+ +nebula> GO FROM "player100" OVER follow YIELD src(edge), dst(edge), type(edge), rank(edge); ++-------------+-------------+------------+------------+ +| src(EDGE) | dst(EDGE) | type(EDGE) | rank(EDGE) | ++-------------+-------------+------------+------------+ +| "player100" | "player101" | "follow" | 0 | ++-------------+-------------+------------+------------+ +| "player100" | "player125" | "follow" | 0 | ++-------------+-------------+------------+------------+ ``` diff --git a/docs-2.0/3.ngql-guide/5.operators/1.comparison.md b/docs-2.0/3.ngql-guide/5.operators/1.comparison.md index e4864848289..5badfa96f3b 100644 --- a/docs-2.0/3.ngql-guide/5.operators/1.comparison.md +++ b/docs-2.0/3.ngql-guide/5.operators/1.comparison.md @@ -190,13 +190,14 @@ nebula> RETURN "a" IS NOT EMPTY; | true | +------------------+ -nebula> GO FROM "player100" OVER * WHERE $$.player.name IS NOT EMPTY YIELD follow._dst; +nebula> GO FROM "player100" OVER * WHERE properties($$).name IS NOT EMPTY YIELD dst(edge); +-------------+ -| follow._dst | +| dst(EDGE) | +-------------+ -| "player125" | +| "team204" | +-------------+ | "player101" | +-------------+ - +| "player125" | ++-------------+ ``` diff --git a/docs-2.0/3.ngql-guide/5.operators/4.pipe.md b/docs-2.0/3.ngql-guide/5.operators/4.pipe.md index 997a7c26f6c..a5bbf533889 100644 --- a/docs-2.0/3.ngql-guide/5.operators/4.pipe.md +++ b/docs-2.0/3.ngql-guide/5.operators/4.pipe.md @@ -18,7 +18,7 @@ nGQL和SQL之间的一个主要区别是子查询的组成方式。 ```ngql nebula> GO FROM "player100" OVER follow \ - YIELD follow._dst AS dstid, $$.player.name AS Name | \ + YIELD dst(edge) AS dstid, properties($$).name AS Name | \ GO FROM $-.dstid OVER follow; +-------------+ @@ -26,6 +26,7 @@ nebula> GO FROM "player100" OVER follow \ +-------------+ | "player101" | +-------------+ +... ``` 用户可以使用`YIELD`显式声明需要返回的结果,如果不使用`YIELD`,默认返回目标点ID。 diff --git a/docs-2.0/3.ngql-guide/5.operators/5.property-reference.md b/docs-2.0/3.ngql-guide/5.operators/5.property-reference.md index b5f730b21bc..d75a4702667 100644 --- a/docs-2.0/3.ngql-guide/5.operators/5.property-reference.md +++ b/docs-2.0/3.ngql-guide/5.operators/5.property-reference.md @@ -18,7 +18,7 @@ nGQL提供引用符来表示`WHERE`和`YIELD`子句中的属性,或者复合 ```ngql # 返回起始点和目的点的年龄。 -nebula> GO FROM "player100" OVER follow YIELD $^.player.age AS SrcAge, $$.player.age AS DestAge; +nebula> GO FROM "player100" OVER follow YIELD properties($^).age AS SrcAge, properties($$).age AS DestAge; +--------+---------+ | SrcAge | DestAge | +--------+---------+ @@ -29,9 +29,9 @@ nebula> GO FROM "player100" OVER follow YIELD $^.player.age AS SrcAge, $$.player # 返回player100追随的player的名称和团队。 nebula> GO FROM "player100" OVER follow \ - YIELD follow._dst AS id | \ + YIELD dst(edge) AS id | \ GO FROM $-.id OVER serve \ - YIELD $^.player.name AS Player, $$.team.name AS Team; + YIELD properties($^).name AS Player, properties($$).name AS Team; +-----------------+-----------+ | Player | Team | +-----------------+-----------+ diff --git a/docs-2.0/3.ngql-guide/5.operators/6.set.md b/docs-2.0/3.ngql-guide/5.operators/6.set.md index d7edceb037c..73407c13571 100644 --- a/docs-2.0/3.ngql-guide/5.operators/6.set.md +++ b/docs-2.0/3.ngql-guide/5.operators/6.set.md @@ -51,18 +51,20 @@ nebula> GO FROM "player102" OVER follow \ # UNION也可以和YIELD语句一起使用,去重时会检查每一行的所有列,每列都相同时才会去重。 nebula> GO FROM "player102" OVER follow \ - YIELD follow._dst AS id, follow.degree AS Degree, $$.player.age AS Age \ + YIELD dst(edge) AS id, properties(edge).degree AS Degree, properties($$).age AS Age \ UNION /* DISTINCT */ \ GO FROM "player100" OVER follow \ - YIELD follow._dst AS id, follow.degree AS Degree, $$.player.age AS Age; + YIELD dst(edge) AS id, properties(edge).degree AS Degree, properties($$).age AS Age; +-------------+--------+-----+ | id | Degree | Age | +-------------+--------+-----+ -| "player101" | 75 | 36 | +| "player100" | 75 | 42 | +-------------+--------+-----+ -| "player101" | 96 | 36 | +| "player101" | 75 | 36 | +-------------+--------+-----+ -| "player102" | 90 | 33 | +| "player101" | 95 | 36 | ++-------------+--------+-----+ +| "player125" | 95 | 41 | +-------------+--------+-----+ ``` @@ -80,10 +82,10 @@ nebula> GO FROM "player102" OVER follow \ ```ngql nebula> GO FROM "player102" OVER follow \ - YIELD follow._dst AS id, follow.degree AS Degree, $$.player.age AS Age \ + YIELD dst(edge) AS id, properties(edge).degree AS Degree, properties($$).age AS Age \ INTERSECT \ GO FROM "player100" OVER follow \ - YIELD follow._dst AS id, follow.degree AS Degree, $$.player.age AS Age; + YIELD dst(edge) AS id, properties(edge).degree AS Degree, properties($$).age AS Age; Empty set (time spent 2990/3511 us) ``` @@ -121,18 +123,22 @@ Empty set (time spent 2243/3259 us) ```ngql nebula> GO FROM "player102" OVER follow \ - YIELD follow._dst AS play_dst \ + YIELD dst(edge) AS play_dst \ UNION \ GO FROM "team200" OVER serve REVERSELY \ - YIELD serve._dst AS play_dst \ - | GO FROM $-.play_dst OVER follow YIELD follow._dst AS play_dst; + YIELD src(edge) AS play_src \ + | GO FROM $-.play_src OVER follow YIELD dst(edge) AS play_dst; +-------------+ | play_dst | +-------------+ +| "player100" | ++-------------+ | "player101" | +-------------+ -| "player102" | +| "player117" | ++-------------+ +| "player105" | +-------------+ ``` @@ -144,11 +150,11 @@ nebula> GO FROM "player102" OVER follow \ ```ngql nebula> (GO FROM "player102" OVER follow \ - YIELD follow._dst AS play_dst \ + YIELD dst(edge) AS play_dst \ UNION \ GO FROM "team200" OVER serve REVERSELY \ - YIELD serve._dst AS play_dst) \ - | GO FROM $-.play_dst OVER follow YIELD follow._dst AS play_dst; + YIELD src(edge) AS play_dst) \ + | GO FROM $-.play_dst OVER follow YIELD dst(edge) AS play_dst; ``` 该查询中,圆括号包裹的部分先执行,即先执行`UNION`操作,再将结果结合管道符进行下一步操作。 diff --git a/docs-2.0/3.ngql-guide/5.operators/7.string.md b/docs-2.0/3.ngql-guide/5.operators/7.string.md index a1b45669b68..5b9bb7ac0fc 100644 --- a/docs-2.0/3.ngql-guide/5.operators/7.string.md +++ b/docs-2.0/3.ngql-guide/5.operators/7.string.md @@ -47,22 +47,22 @@ nebula> MATCH (s:player)-[e:serve]->(t:team) WHERE id(s) == "player101" \ | "Tony Parker" | 2018 | 2019 | "Hornets" | +---------------+--------------+------------+-----------+ -nebula> GO FROM "player101" OVER serve WHERE (STRING)serve.start_year CONTAINS "19" AND \ - $^.player.name CONTAINS "ny" \ - YIELD $^.player.name, serve.start_year, serve.end_year, $$.team.name; -+----------------+------------------+----------------+--------------+ -| $^.player.name | serve.start_year | serve.end_year | $$.team.name | -+----------------+------------------+----------------+--------------+ -| "Tony Parker" | 1999 | 2018 | "Spurs" | -+----------------+------------------+----------------+--------------+ - -nebula> GO FROM "player101" OVER serve WHERE !($$.team.name CONTAINS "ets") \ - YIELD $^.player.name, serve.start_year, serve.end_year, $$.team.name; -+----------------+------------------+----------------+--------------+ -| $^.player.name | serve.start_year | serve.end_year | $$.team.name | -+----------------+------------------+----------------+--------------+ -| "Tony Parker" | 1999 | 2018 | "Spurs" | -+----------------+------------------+----------------+--------------+ +nebula> GO FROM "player101" OVER serve WHERE (STRING)properties(edge).start_year CONTAINS "19" AND \ + properties($^).name CONTAINS "ny" \ + YIELD properties($^).name, properties(edge).start_year, properties(edge).end_year, properties($$).name; ++---------------------+-----------------------------+---------------------------+---------------------+ +| properties($^).name | properties(EDGE).start_year | properties(EDGE).end_year | properties($$).name | ++---------------------+-----------------------------+---------------------------+---------------------+ +| "Tony Parker" | 1999 | 2018 | "Spurs" | ++---------------------+-----------------------------+---------------------------+---------------------+ + +nebula> GO FROM "player101" OVER serve WHERE !(properties($$).name CONTAINS "ets") \ + YIELD properties($^).name, properties(edge).start_year, properties(edge).end_year, properties($$).name; ++---------------------+-----------------------------+---------------------------+---------------------+ +| properties($^).name | properties(EDGE).start_year | properties(EDGE).end_year | properties($$).name | ++---------------------+-----------------------------+---------------------------+---------------------+ +| "Tony Parker" | 1999 | 2018 | "Spurs" | ++---------------------+-----------------------------+---------------------------+---------------------+ ``` ### `(NOT) IN` diff --git a/docs-2.0/3.ngql-guide/6.functions-and-expressions/1.math.md b/docs-2.0/3.ngql-guide/6.functions-and-expressions/1.math.md index aea116c3d72..9e7e1ea1eb8 100644 --- a/docs-2.0/3.ngql-guide/6.functions-and-expressions/1.math.md +++ b/docs-2.0/3.ngql-guide/6.functions-and-expressions/1.math.md @@ -53,18 +53,18 @@ Nebula Graph支持以下内置数学函数。 ```ngql # 支持聚合函数 -nebula> GO FROM "Tim Duncan" OVER like YIELD like._dst AS dst, $$.player.age AS age \ +nebula> GO FROM "player100" OVER follow YIELD dst(edge) AS dst, properties($$).age AS age \ | GROUP BY $-.dst \ YIELD \ $-.dst AS dst, \ toInteger((sum($-.age)/count($-.age)))+avg(distinct $-.age+1)+1 AS statistics; -+-----------------+------------+ -| dst | statistics | -+-----------------+------------+ -| "Tony Parker" | 74.0 | -+-----------------+------------+ -| "Manu Ginobili" | 84.0 | -+-----------------+------------+ ++-------------+------------+ +| dst | statistics | ++-------------+------------+ +| "player125" | 84.0 | ++-------------+------------+ +| "player101" | 74.0 | ++-------------+------------+ Got 2 rows (time spent 4739/5064 us) ``` diff --git a/docs-2.0/3.ngql-guide/6.functions-and-expressions/11.reduce.md b/docs-2.0/3.ngql-guide/6.functions-and-expressions/11.reduce.md index 1d6a59e82f4..14d0f31baa0 100644 --- a/docs-2.0/3.ngql-guide/6.functions-and-expressions/11.reduce.md +++ b/docs-2.0/3.ngql-guide/6.functions-and-expressions/11.reduce.md @@ -62,8 +62,8 @@ nebula> MATCH p = (n:player{name:"LeBron James"})<-[:follow]-(m) \ nebula> LOOKUP ON player WHERE player.name == "Tony Parker" \ | GO FROM $-.VertexID over follow \ - WHERE follow.degree != reduce(totalNum = 5, n IN range(1, 3) | $$.player.age + totalNum + n) \ - YIELD $$.player.name AS id, $$.player.age AS age, follow.degree AS degree; + WHERE properties(edge).degree != reduce(totalNum = 5, n IN range(1, 3) | properties($$).age + totalNum + n) \ + YIELD properties($$).name AS id, properties($$).age AS age, properties(edge).degree AS degree; +---------------------+-----+--------+ | id | age | degree | +---------------------+-----+--------+ diff --git a/docs-2.0/3.ngql-guide/6.functions-and-expressions/13.concat.md b/docs-2.0/3.ngql-guide/6.functions-and-expressions/13.concat.md index 6e459ba385e..de585aa43e7 100644 --- a/docs-2.0/3.ngql-guide/6.functions-and-expressions/13.concat.md +++ b/docs-2.0/3.ngql-guide/6.functions-and-expressions/13.concat.md @@ -35,7 +35,7 @@ nebula> RETURN concat("1","2",NULL) AS r; +----------+ nebula> GO FROM "player100" over follow \ - YIELD concat(follow._src, $^.player.age, $$.player.name, follow.degree) AS A; + YIELD concat(src(edge), properties($^).age, properties($$).name, properties(edge).degree) AS A; +------------------------------+ | A | +------------------------------+ @@ -97,7 +97,7 @@ nebula> RETURN concat_ws("+","a") AS r; +-----+ nebula> GO FROM "player100" over follow \ - YIELD concat_ws(" ",follow._src, $^.player.age, $$.player.name, follow.degree) AS A; + YIELD concat_ws(" ",src(edge), properties($^).age, properties($$).name, properties(edge).degree) AS A; +---------------------------------+ | A | +---------------------------------+ diff --git a/docs-2.0/3.ngql-guide/6.functions-and-expressions/4.schema.md b/docs-2.0/3.ngql-guide/6.functions-and-expressions/4.schema.md index c577cceee5d..723598ca936 100644 --- a/docs-2.0/3.ngql-guide/6.functions-and-expressions/4.schema.md +++ b/docs-2.0/3.ngql-guide/6.functions-and-expressions/4.schema.md @@ -1,27 +1,63 @@ # Schema函数 -!!! note +Nebula Graph支持以下Schema函数。 - 本文介绍的函数仅适用于openCypher兼容语句。 +## 原生nGQL语句适用 -Nebula Graph支持以下Schema函数。 +!!! note + + - GO语句中,WHERE子句和YIELD子句中可以使用如下函数。 + - LOOKUP语句中,YIELD子句中可以使用如下函数。 + - FETCH语句中,YIELD子句中可以使用如下函数。 |函数| 说明 | |:---- | :----| -| id(vertex) | 返回点ID。数据类型和点ID的类型保持一致。| -|list tags(vertex) | 返回点的Tag,与labels()作用相同。| -|list labels(vertex) | 返回点的Tag,与tags()作用相同,用于兼容openCypher语法。| -|map properties(vertex_or_edge) | 接收点或边并返回其属性。| +|id(vertex) | 返回点ID。数据类型和点ID的类型保持一致。| +|map properties(vertex) | 返回点的所有属性。| +|map properties(edge) | 返回边的所有属性。| |string type(edge) | 返回边的Edge type。| |src(edge)|返回边的起始点ID。数据类型和点ID的类型保持一致。| |dst(edge)|返回边的目的点ID。数据类型和点ID的类型保持一致。| -|vertex startNode(path) | 获取一条边或一条路径并返回它的起始点ID。| -|string endNode(path) | 获取一条边或一条路径并返回它的目的点ID。| |int rank(edge) | 返回边的rank。| +## openCypher兼容语句适用 + +|函数| 说明 | +|:---- | :----| +| id(\) | 返回点ID。数据类型和点ID的类型保持一致。| +|list tags(\) | 返回点的Tag,与labels()作用相同。| +|list labels(\) | 返回点的Tag,与tags()作用相同,用于兼容openCypher语法。| +|map properties(\) | 返回点或边的所有属性。| +|string type(\) | 返回边的Edge type。| +|src(\)|返回边的起始点ID。数据类型和点ID的类型保持一致。| +|dst(\)|返回边的目的点ID。数据类型和点ID的类型保持一致。| +|vertex startNode(\) | 获取一条边或一条路径并返回它的起始点ID。| +|string endNode(\) | 获取一条边或一条路径并返回它的目的点ID。| +|int rank(\) | 返回边的rank。| + ## 示例 ```ngql +nebula> GO FROM "player100" OVER follow REVERSELY \ + YIELD src(edge) AS destination; ++-------------+ +| destination | ++-------------+ +| "player101" | ++-------------+ +| "player102" | ++-------------+ + +nebula> LOOKUP ON player WHERE player.age > 45 YIELD id(vertex); ++-------------+-------------+ +| VertexID | id(VERTEX) | ++-------------+-------------+ +| "player144" | "player144" | ++-------------+-------------+ +| "player140" | "player140" | ++-------------+-------------+ + + nebula> MATCH (a:player) WHERE id(a) == "player100" \ RETURN tags(a), labels(a), properties(a); +------------+------------+-------------------------------+ diff --git a/docs-2.0/3.ngql-guide/6.functions-and-expressions/5.case-expressions.md b/docs-2.0/3.ngql-guide/6.functions-and-expressions/5.case-expressions.md index 27f726bab57..921dcbd6d54 100644 --- a/docs-2.0/3.ngql-guide/6.functions-and-expressions/5.case-expressions.md +++ b/docs-2.0/3.ngql-guide/6.functions-and-expressions/5.case-expressions.md @@ -46,20 +46,20 @@ nebula> RETURN \ ```ngql nebula> GO FROM "player100" OVER follow \ - YIELD $$.player.name AS Name, \ - CASE $$.player.age > 35 \ + YIELD properties($$).name AS Name, \ + CASE properties($$).age > 35 \ WHEN true THEN "Yes" \ WHEN false THEN "No" \ ELSE "Nah" \ END \ AS Age_above_35; -+---------------------+--------------+ -| Name | Age_above_35 | -+---------------------+--------------+ -| "Tony Parker" | "Yes" | -+---------------------+--------------+ -| "LaMarcus Aldridge" | "No" | -+---------------------+--------------+ ++-----------------+--------------+ +| Name | Age_above_35 | ++-----------------+--------------+ +| "Tony Parker" | "Yes" | ++-----------------+--------------+ +| "Manu Ginobili" | "Yes" | ++-----------------+--------------+ ``` ## 通用形式 @@ -121,9 +121,9 @@ nebula> MATCH (v:player) WHERE v.age > 30 \ ```ngql nebula> GO FROM "player100" OVER follow \ - YIELD $$.player.name AS Name, $$.player.age AS Age, \ - CASE $$.player.age \ - WHEN $$.player.age > 35 THEN "Yes" \ + YIELD properties($$).name AS Name, properties($$).age AS Age, \ + CASE properties($$).age \ + WHEN properties($$).age > 35 THEN "Yes" \ ELSE "No" \ END \ AS Age_above_35; diff --git a/docs-2.0/3.ngql-guide/6.functions-and-expressions/7.count.md b/docs-2.0/3.ngql-guide/6.functions-and-expressions/7.count.md index 6fa5178aeaf..f749b96fbf1 100644 --- a/docs-2.0/3.ngql-guide/6.functions-and-expressions/7.count.md +++ b/docs-2.0/3.ngql-guide/6.functions-and-expressions/7.count.md @@ -33,7 +33,7 @@ nebula> WITH [NULL, 1, 1, 2, 2] As a UNWIND a AS b \ ```ngql # 返回player101 follow的人,以及follow player101的人,即双向查询。 nebula> GO FROM "player101" OVER follow BIDIRECT \ - YIELD $$.player.name AS Name \ + YIELD properties($$).name AS Name \ | GROUP BY $-.Name YIELD $-.Name, count(*); +---------------------+----------+ | $-.Name | count(*) | diff --git a/docs-2.0/3.ngql-guide/7.general-query-statements/2.match.md b/docs-2.0/3.ngql-guide/7.general-query-statements/2.match.md index e0e8769dcc8..a153a53237f 100644 --- a/docs-2.0/3.ngql-guide/7.general-query-statements/2.match.md +++ b/docs-2.0/3.ngql-guide/7.general-query-statements/2.match.md @@ -11,7 +11,7 @@ 与`GO`或`LOOKUP`等其他查询语句相比,`MATCH`的语法更灵活。`MATCH`语法可以概括如下: ```ngql -MATCH [] RETURN +MATCH [] RETURN ; ``` ## MATCH工作流程 diff --git a/docs-2.0/3.ngql-guide/7.general-query-statements/3.go.md b/docs-2.0/3.ngql-guide/7.general-query-statements/3.go.md index 3eeb74d47fb..193e00c0afd 100644 --- a/docs-2.0/3.ngql-guide/7.general-query-statements/3.go.md +++ b/docs-2.0/3.ngql-guide/7.general-query-statements/3.go.md @@ -15,7 +15,7 @@ OVER [{REVERSELY | BIDIRECT}] [YIELD [DISTINCT] ] [| GROUP BY {col_name | expr | position} YIELD ] [| ORDER BY [{ASC | DESC}]] -[| LIMIT [,] ] +[| LIMIT [,] ]; ::= [, ...] diff --git a/docs-2.0/3.ngql-guide/7.general-query-statements/4.fetch.md b/docs-2.0/3.ngql-guide/7.general-query-statements/4.fetch.md index 504d958187e..3c3ff6ced18 100644 --- a/docs-2.0/3.ngql-guide/7.general-query-statements/4.fetch.md +++ b/docs-2.0/3.ngql-guide/7.general-query-statements/4.fetch.md @@ -45,7 +45,7 @@ nebula> FETCH PROP ON player "player100"; ```ngql nebula> FETCH PROP ON player "player100" \ - YIELD player.name AS name; + YIELD properties(vertex).name AS name; +-------------+--------------+ | VertexID | name | +-------------+--------------+ @@ -155,12 +155,12 @@ nebula> FETCH PROP ON serve "player100" -> "team204"; ```ngql nebula> FETCH PROP ON serve "player100" -> "team204" \ - YIELD serve.start_year; -+-------------+------------+-------------+------------------+ -| serve._src | serve._dst | serve._rank | serve.start_year | -+-------------+------------+-------------+------------------+ -| "player100" | "team204" | 0 | 1997 | -+-------------+------------+-------------+------------------+ + YIELD properties(edge).start_year; ++-------------+------------+-------------+-----------------------------+ +| serve._src | serve._dst | serve._rank | properties(EDGE).start_year | ++-------------+------------+-------------+-----------------------------+ +| "player100" | "team204" | 0 | 1997 | ++-------------+------------+-------------+-----------------------------+ ``` ### 获取多条边的属性值 @@ -214,36 +214,36 @@ nebula> FETCH PROP ON serve "player100" -> "team204"@1; ```ngql # 返回从点player101开始的follow边的degree值。 nebula> GO FROM "player101" OVER follow \ - YIELD follow._src AS s, follow._dst AS d \ + YIELD src(edge) AS s, dst(edge) AS d \ | FETCH PROP ON follow $-.s -> $-.d \ - YIELD follow.degree; -+-------------+-------------+--------------+---------------+ -| follow._src | follow._dst | follow._rank | follow.degree | -+-------------+-------------+--------------+---------------+ -| "player101" | "player100" | 0 | 95 | -+-------------+-------------+--------------+---------------+ -| "player101" | "player102" | 0 | 90 | -+-------------+-------------+--------------+---------------+ -| "player101" | "player125" | 0 | 95 | -+-------------+-------------+--------------+---------------+ + YIELD properties(edge).degree; ++-------------+-------------+--------------+-------------------------+ +| follow._src | follow._dst | follow._rank | properties(EDGE).degree | ++-------------+-------------+--------------+-------------------------+ +| "player101" | "player100" | 0 | 95 | ++-------------+-------------+--------------+-------------------------+ +| "player101" | "player102" | 0 | 90 | ++-------------+-------------+--------------+-------------------------+ +| "player101" | "player125" | 0 | 95 | ++-------------+-------------+--------------+-------------------------+ ``` 用户也可以通过自定义变量构建类似的查询。 ```ngql nebula> $var = GO FROM "player101" OVER follow \ - YIELD follow._src AS s, follow._dst AS d; \ + YIELD src(edge) AS s, dst(edge) AS d; \ FETCH PROP ON follow $var.s -> $var.d \ - YIELD follow.degree; -+-------------+-------------+--------------+---------------+ -| follow._src | follow._dst | follow._rank | follow.degree | -+-------------+-------------+--------------+---------------+ -| "player101" | "player100" | 0 | 95 | -+-------------+-------------+--------------+---------------+ -| "player101" | "player102" | 0 | 90 | -+-------------+-------------+--------------+---------------+ -| "player101" | "player125" | 0 | 95 | -+-------------+-------------+--------------+---------------+ + YIELD properties(edge).degree; ++-------------+-------------+--------------+-------------------------+ +| follow._src | follow._dst | follow._rank | properties(EDGE).degree | ++-------------+-------------+--------------+-------------------------+ +| "player101" | "player100" | 0 | 95 | ++-------------+-------------+--------------+-------------------------+ +| "player101" | "player102" | 0 | 90 | ++-------------+-------------+--------------+-------------------------+ +| "player101" | "player125" | 0 | 95 | ++-------------+-------------+--------------+-------------------------+ ``` 更多复合语句的详情,请参见[复合查询(子句结构)](../4.variable-and-composite-queries/1.composite-queries.md)。 diff --git a/docs-2.0/3.ngql-guide/7.general-query-statements/5.lookup.md b/docs-2.0/3.ngql-guide/7.general-query-statements/5.lookup.md index 0b4a226e988..ff54b15e198 100644 --- a/docs-2.0/3.ngql-guide/7.general-query-statements/5.lookup.md +++ b/docs-2.0/3.ngql-guide/7.general-query-statements/5.lookup.md @@ -86,7 +86,7 @@ nebula> LOOKUP ON player \ nebula> LOOKUP ON player \ WHERE player.name == "Tony Parker" \ - YIELD player.name AS name, player.age AS age; + YIELD properties(vertex).name AS name, properties(vertex).age AS age; +-------------+---------------+-----+ | VertexID | name | age | +-------------+---------------+-----+ @@ -106,20 +106,20 @@ nebula> LOOKUP ON player \ nebula> LOOKUP ON player \ WHERE player.name STARTS WITH "B" \ AND player.age IN [22,30] \ - YIELD player.name, player.age; -+-------------+-----------------+------------+ -| VertexID | player.name | player.age | -+-------------+-----------------+------------+ -| "player149" | "Ben Simmons" | 22 | -+-------------+-----------------+------------+ -| "player134" | "Blake Griffin" | 30 | -+-------------+-----------------+------------+ + YIELD properties(vertex).name, properties(vertex).age; ++-------------+-------------------------+------------------------+ +| VertexID | properties(VERTEX).name | properties(VERTEX).age | ++-------------+-------------------------+------------------------+ +| "player149" | "Ben Simmons" | 22 | ++-------------+-------------------------+------------------------+ +| "player134" | "Blake Griffin" | 30 | ++-------------+-------------------------+------------------------+ nebula> LOOKUP ON player \ - WHERE player.name == "Kobe Bryant" \ - YIELD player.name AS name |\ + WHERE player.name == "Kobe Bryant"\ + YIELD properties(vertex).name AS name |\ GO FROM $-.VertexID OVER serve \ - YIELD $-.name, serve.start_year, serve.end_year, $$.team.name; + YIELD $-.name, properties(edge).start_year, properties(edge).end_year, properties($$).name; +---------------+------------------+----------------+--------------+ | $-.name | serve.start_year | serve.end_year | $$.team.name | +---------------+------------------+----------------+--------------+ @@ -156,23 +156,23 @@ nebula> LOOKUP ON follow \ nebula> LOOKUP ON follow \ WHERE follow.degree == 90 \ - YIELD follow.degree; -+-------------+-------------+---------+---------------+ -| SrcVID | DstVID | Ranking | follow.degree | -+-------------+-------------+---------+---------------+ -| "player101" | "player102" | 0 | 90 | -+-------------+-------------+---------+---------------+ -| "player133" | "player114" | 0 | 90 | -+-------------+-------------+---------+---------------+ -| "player133" | "player144" | 0 | 90 | -+-------------+-------------+---------+---------------+ + YIELD properties(edge).degree; ++-------------+-------------+---------+-------------------------+ +| SrcVID | DstVID | Ranking | properties(EDGE).degree | ++-------------+-------------+---------+-------------------------+ +| "player121" | "player116" | 0 | 90 | ++-------------+-------------+---------+-------------------------+ +| "player121" | "player128" | 0 | 90 | ++-------------+-------------+---------+-------------------------+ +| "player121" | "player129" | 0 | 90 | ++-------------+-------------+---------+-------------------------+ ... nebula> LOOKUP ON follow \ WHERE follow.degree == 60 \ - YIELD follow.degree AS Degree |\ + YIELD properties(edge).degree AS Degree |\ GO FROM $-.DstVID OVER serve \ - YIELD $-.DstVID, serve.start_year, serve.end_year, $$.team.name; + YIELD $-.DstVID, properties(edge).start_year, properties(edge).end_year, properties($$).name; +-------------+------------------+----------------+--------------+ | $-.DstVID | serve.start_year | serve.end_year | $$.team.name | +-------------+------------------+----------------+--------------+ diff --git a/docs-2.0/3.ngql-guide/8.clauses-and-options/group-by.md b/docs-2.0/3.ngql-guide/8.clauses-and-options/group-by.md index d65e11fb842..dacbdc47afd 100644 --- a/docs-2.0/3.ngql-guide/8.clauses-and-options/group-by.md +++ b/docs-2.0/3.ngql-guide/8.clauses-and-options/group-by.md @@ -42,7 +42,7 @@ nebula> MATCH (v:player)<-[:follow]-(:player) RETURN v.name AS Name, count(*) a ```ngql # 查找所有连接到player100的点,并根据他们的姓名进行分组,返回姓名的出现次数。 nebula> GO FROM "player100" OVER follow BIDIRECT \ - YIELD $$.player.name as Name \ + YIELD properties($$).name as Name \ | GROUP BY $-.Name \ YIELD $-.Name as Player, count(*) AS Name_Count; +---------------------+------------+ @@ -75,7 +75,7 @@ nebula> GO FROM "player100" OVER follow BIDIRECT \ ```ngql # 查找所有连接到player100的点,并根据起始点进行分组,返回degree的总和。 nebula> GO FROM "player100" OVER follow \ - YIELD follow._src AS player, follow.degree AS degree \ + YIELD src(edge) AS player, properties(edge).degree AS degree \ | GROUP BY $-.player \ YIELD sum($-.degree); +----------------+ diff --git a/docs-2.0/3.ngql-guide/8.clauses-and-options/limit.md b/docs-2.0/3.ngql-guide/8.clauses-and-options/limit.md index 94ab6de5624..cb87e926de1 100644 --- a/docs-2.0/3.ngql-guide/8.clauses-and-options/limit.md +++ b/docs-2.0/3.ngql-guide/8.clauses-and-options/limit.md @@ -30,7 +30,7 @@ YIELD ```ngql # 从排序结果中返回第2行开始的3行数据。 nebula> GO FROM "player100" OVER follow REVERSELY \ - YIELD $$.player.name AS Friend, $$.player.age AS Age \ + YIELD properties($$).name AS Friend, properties($$).age AS Age \ | ORDER BY $-.Age, $-.Friend \ | LIMIT 1, 3; +-------------------+-----+ diff --git a/docs-2.0/3.ngql-guide/8.clauses-and-options/order-by.md b/docs-2.0/3.ngql-guide/8.clauses-and-options/order-by.md index d411817086f..8023384e648 100644 --- a/docs-2.0/3.ngql-guide/8.clauses-and-options/order-by.md +++ b/docs-2.0/3.ngql-guide/8.clauses-and-options/order-by.md @@ -26,7 +26,7 @@ ORDER BY [ASC | DESC] [, [ASC | DESC] ...]; ```ngql nebula> FETCH PROP ON player "player100", "player101", "player102", "player103" \ - YIELD player.age AS age, player.name AS name \ + YIELD properties(vertex).age AS age, properties(vertex).name AS name \ | ORDER BY $-.age ASC, $-.name DESC; +-------------+-----+---------------------+ | VertexID | age | name | @@ -41,7 +41,7 @@ nebula> FETCH PROP ON player "player100", "player101", "player102", "player103" +-------------+-----+---------------------+ nebula> $var = GO FROM "player100" OVER follow \ - YIELD follow._dst AS dst; \ + YIELD dst(edge) AS dst; \ ORDER BY $var.dst DESC; +-------------+ | dst | diff --git a/docs-2.0/3.ngql-guide/8.clauses-and-options/where.md b/docs-2.0/3.ngql-guide/8.clauses-and-options/where.md index 35643bcec6d..02c46f46ac7 100644 --- a/docs-2.0/3.ngql-guide/8.clauses-and-options/where.md +++ b/docs-2.0/3.ngql-guide/8.clauses-and-options/where.md @@ -48,16 +48,15 @@ nebula> MATCH (v:player) \ ```ngql nebula> GO FROM "player100" \ OVER follow \ - WHERE follow.degree > 90 \ - OR $$.player.age != 33 \ - AND $$.player.name != "Tony Parker"; -+-------------+ -| follow._dst | -+-------------+ -| "player101" | -+-------------+ -| "player125" | -+-------------+ + WHERE properties(edge).degree > 90 \ + OR properties($$).age != 33 \ + AND properties($$).name != "Tony Parker" \ + YIELD properties($$); ++----------------------------------+ +| properties($$) | ++----------------------------------+ +| {age: 41, name: "Manu Ginobili"} | ++----------------------------------+ ``` ### 过滤属性 @@ -180,20 +179,20 @@ nebula> INSERT EDGE e1(p1) VALUES "1"->"2"@6:(16); # 通过rank过滤边,查找rank大于2的边。 nebula> GO FROM "1" \ OVER e1 \ - WHERE e1._rank>2 \ - YIELD e1._src, e1._dst, e1._rank AS Rank, e1.p1 | \ + WHERE rank(edge) > 2 \ + YIELD src(edge), dst(edge), rank(edge) AS Rank, properties(edge).p1 | \ ORDER BY $-.Rank DESC; -==================================== -| e1._src | e1._dst | Rank | e1.p1 | -==================================== -| 1 | 2 | 6 | 16 | ------------------------------------- -| 1 | 2 | 5 | 15 | ------------------------------------- -| 1 | 2 | 4 | 14 | ------------------------------------- -| 1 | 2 | 3 | 13 | ------------------------------------- ++-----------+-----------+------+---------------------+ +| src(EDGE) | dst(EDGE) | Rank | properties(EDGE).p1 | ++-----------+-----------+------+---------------------+ +| "1" | "2" | 6 | 16 | ++-----------+-----------+------+---------------------+ +| "1" | "2" | 5 | 15 | ++-----------+-----------+------+---------------------+ +| "1" | "2" | 4 | 14 | ++-----------+-----------+------+---------------------+ +| "1" | "2" | 3 | 13 | ++-----------+-----------+------+---------------------+ ``` ## 过滤字符串 @@ -335,20 +334,20 @@ nebula> MATCH (v:player) \ | "Joel Embiid" | 25 | +-------------------------+-------+ -nebula> LOOKUP ON player WHERE player.age IN [25,28] YIELD player.name, player.age; -+-------------+------------------+------------+ -| VertexID | player.name | player.age | -+-------------+------------------+------------+ -| "player135" | "Damian Lillard" | 28 | -+-------------+------------------+------------+ -| "player131" | "Paul George" | 28 | -+-------------+------------------+------------+ -| "player130" | "Joel Embiid" | 25 | -+-------------+------------------+------------+ -| "player123" | "Ricky Rubio" | 28 | -+-------------+------------------+------------+ -| "player106" | "Kyle Anderson" | 25 | -+-------------+------------------+------------+ +nebula> LOOKUP ON player WHERE player.age IN [25,28] YIELD properties(vertex).name, properties(vertex).age; ++-------------+-------------------------+------------------------+ +| VertexID | properties(VERTEX).name | properties(VERTEX).age | ++-------------+-------------------------+------------------------+ +| "player106" | "Kyle Anderson" | 25 | ++-------------+-------------------------+------------------------+ +| "player135" | "Damian Lillard" | 28 | ++-------------+-------------------------+------------------------+ +| "player130" | "Joel Embiid" | 25 | ++-------------+-------------------------+------------------------+ +| "player131" | "Paul George" | 28 | ++-------------+-------------------------+------------------------+ +| "player123" | "Ricky Rubio" | 28 | ++-------------+-------------------------+------------------------+ ``` ### 结合NOT使用 diff --git a/docs-2.0/3.ngql-guide/8.clauses-and-options/yield.md b/docs-2.0/3.ngql-guide/8.clauses-and-options/yield.md index 6f643e4a95d..f2289cc1ca8 100644 --- a/docs-2.0/3.ngql-guide/8.clauses-and-options/yield.md +++ b/docs-2.0/3.ngql-guide/8.clauses-and-options/yield.md @@ -59,24 +59,24 @@ YIELD [DISTINCT] [AS ] [, [AS ] ...]; ```ngql nebula> FETCH PROP ON player "player100" \ - YIELD player.name; - +-------------+--------------+ - | VertexID | player.name | - +-------------+--------------+ - | "player100" | "Tim Duncan" | - +-------------+--------------+ + YIELD properties(vertex).name; + +-------------+-------------------------+ + | VertexID | properties(VERTEX).name | + +-------------+-------------------------+ + | "player100" | "Tim Duncan" | + +-------------+-------------------------+ ``` - `LOOKUP`语句中使用`YIELD`: ```ngql nebula> LOOKUP ON player WHERE player.name == "Tony Parker" \ - YIELD player.name, player.age; - +-------------+---------------+------------+ - | VertexID | player.name | player.age | - +-------------+---------------+------------+ - | "player101" | "Tony Parker" | 36 | - +-------------+---------------+------------+ + YIELD properties(vertex).name, properties(vertex).age; + +-------------+-------------------------+------------------------+ + | VertexID | properties(VERTEX).name | properties(VERTEX).age | + +-------------+-------------------------+------------------------+ + | "player101" | "Tony Parker" | 36 | + +-------------+-------------------------+------------------------+ ``` ## YIELD语句 @@ -104,7 +104,7 @@ YIELD [DISTINCT] [AS ] [, [AS ] ...] nebula> GO FROM "player100" OVER follow \ YIELD dst(edge) AS ID \ | FETCH PROP ON player $-.ID \ - YIELD player.age AS Age \ + YIELD properties(vertex).age AS Age \ | YIELD AVG($-.Age) as Avg_age, count(*)as Num_friends; +---------+-------------+ | Avg_age | Num_friends | diff --git a/docs-2.0/nebula-studio/use-console/st-ug-open-in-explore.md b/docs-2.0/nebula-studio/use-console/st-ug-open-in-explore.md index e58ef4f3ef3..ffeb8e77cc1 100644 --- a/docs-2.0/nebula-studio/use-console/st-ug-open-in-explore.md +++ b/docs-2.0/nebula-studio/use-console/st-ug-open-in-explore.md @@ -30,7 +30,7 @@ Studio v{{ studio.release }} 及以后版本。请更新版本,详细操作参 查询语句示例如下: ```nGQL - nebula> GO FROM "player102" OVER serve YIELD serve._src,serve._dst; + nebula> GO FROM "player102" OVER serve YIELD src(edge),dst(edge); ``` 查询结果可以看到 `playerId` 为 `palyer102` 的球员服务球队的起始年份及终止年份。如下图所示。 @@ -81,7 +81,7 @@ Studio v{{ studio.release }} 及以后版本。请更新版本,详细操作参 查询语句示例如下: ```nGQL - nebula> FETCH PROP ON player "player100" YIELD player.name; + nebula> FETCH PROP ON player "player100" YIELD properties(vertex).name; ``` 查询得到 `playerId` 为 `player100` 的球员信息。如下图所示。