Skip to content

Commit

Permalink
Fixed query doc errors (vesoft-inc#1196)
Browse files Browse the repository at this point in the history
  • Loading branch information
amber-moe authored and dutor committed Nov 4, 2019
1 parent 9dbb18f commit 43563ba
Show file tree
Hide file tree
Showing 19 changed files with 51 additions and 55 deletions.
2 changes: 1 addition & 1 deletion docs/manual-CN/2.query-language/0.README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# 面向的读者

本章介绍Nebula Graph的查询语言,适合所有Nebula的用户
本章介绍 Nebula Graph 的查询语言,适合所有使用 Nebula 的用户
1 change: 1 addition & 0 deletions docs/manual-CN/2.query-language/1.data-types/data-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Nebula Graph 支持的内建数据类型如下:
## 时间戳类型

- 时间戳类型的取值范围为 '1970-01-01 00:00:01' UTC 到 '2262-04-11 23:47:16' UTC
- 时间戳单位为秒
- 插入数据的时候,支持插入方式
- 调用函数 now()
- 时间字符串, 例如:"2019-10-01 10:00:00"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ INSERT VERTEX t1 (i1), t2(s2) VALUES 21: (321, "hello") -- 插入有两个标
同一节点可被多次插入或写入,读取时以最后一次插入为准。

```
-- 为点11多次插入新值
-- 为点 11 多次插入新值
INSERT VERTEX t2 (name, age) VALUES 11:("n2", 13)
INSERT VERTEX t2 (name, age) VALUES 11:("n3", 14)
INSERT VERTEX t2 (name, age) VALUES 11:("n4", 15)  -- 读取最后插入的值
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# UPDATE 语法

Nebula 支持 `UPDATE` 一个点或者一条边的属性,支持CAS操作,支持返回相关的属性。
Nebula 支持 `UPDATE` 一个点或者一条边的属性,支持 CAS 操作,支持返回相关的属性。

## 更新点

Expand All @@ -13,7 +13,7 @@ UPDATE VERTEX $vid SET $update_columns WHEN $condition YIELD $columns
- `$vid` 表示需要更新的 vertex ID。
- `$update_columns` 表示需要更新的 tag 上的 columns,比如 `tag1.col1 = $^.tag2.col2 + 1` 表示把这个点的 `tag1.col1` 更新成 `tag2.col2 + 1`

**注意:**  `$^`表示 `UPDATE` 中表示需要更新的点
**注意:**  `$^`表示 `UPDATE` 中需要更新的点

- `$condition` 是一些约束条件,只有满足这个条件,`UPDATE` 才会真正执行,支持表达式操作。
- `$columns` 表示需要返回的 columns,此处 `YIELD` 可返回 update 以后最新的 columns 值。
Expand Down Expand Up @@ -47,4 +47,4 @@ nebula> UPDATE EDGE 200 -> 101@0 OF select SET grade = select.grade + 1, \
YIELD $^.student.name AS Name, select.grade AS Grade, select.year AS Year
```

**注意**本例中 `WHEN` 后面的约束条件为起点 student 这个 tag 的 age 属性,同时也返回了点和边的属性。
**注意**本例中 `WHEN` 后面的约束条件为起点 student 这个 tag 的 age 属性,同时也返回了点和边的属性。
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ YIELD
[, <col_name> [AS <col_alias>] ...]
```

常用于返回由 `GO`(详情请参阅 `GO` 用法)语句生成的结果。
常用于返回由 `GO`(详情请参阅 [GO](go-syntax.md) 用法)语句生成的结果。

```SQL
nebula> GO FROM 201 OVER relations_edge YIELD $$.student.name AS Friend, \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ DESCRIBE EDGE edge_name

DESCRIBE 关键词的作用是获取关于 space, tag, edge 结构的信息。

同时需要注意的是,DESCRIBE 和 SHOW 也是不同的。 详细参见 SHOW 文档。
同时需要注意的是,DESCRIBE 和 SHOW 也是不同的。 详细参见 [SHOW](show-syntax.md) 文档。

## 示例

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ SHOW CONFIG [graph|meta|storage]

`SHOW HOSTS` 列出元服务器注册的所有存储主机。

更多关于 `SHOW VARIABLES [graph|meta|storage]` 的信息,variable syntax一节
更多关于 `SHOW CONFIGS [graph|meta|storage]` 的信息,参见 [configs syntax](../../../3.build-develop-and-administration/3.deploy-and-administrations/server-administration/configuration-statements/configs-syntax.md)

## 示例

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ nebula> USE space1;

和 SQL 不同的是,选取一个当前的工作图空间会阻止你访问其他图空间。遍历一个新的图空间的唯一方案是通过 `USE` 语句来切换工作图空间

> SPACES 之间是 `完全隔离的`。不像 SQL 允许在一个语句中选择两个来自不同数据库的表单,在 Nebula 中一时间只能对一个图空间进行操作
> SPACES 之间是 `完全隔离的`。不像 SQL 允许在一个语句中选择两个来自不同数据库的表单,在 Nebula 中一次只能对一个图空间进行操作
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# FIND PATH 语法

`FIND PATH` 语句用于获取最短路径及全路径
`FIND PATH` 语法用于获取最短路径及全路径

```
FIND SHORTEST | ALL PATH FROM <vertex_id_list> TO <vertex_id_list>
Expand All @@ -11,11 +11,11 @@ OVER <edge_type_list> [UPTO <N> STEPS]

`ALL` 寻找全路径关键词。

`<vertex_id_list>::=[vertex_id [, vertex_id]]` 节点列表,用逗号隔开。支持输入 ```$-``` 及变量 ```$var```
`<vertex_id_list>::=[vertex_id [, vertex_id]]` 为节点列表,用逗号隔开。支持输入 ```$-``` 及变量 ```$var```

`<edge_type_list>` 指定边的类型,多种边类型用 ```,``` 隔开,用 ```*``` 表示所有边类型。

`<N>` 跳数,默认值 5。
`<N>` 为跳数,默认值 5。

## 注意事项

Expand Down
1 change: 1 addition & 0 deletions docs/manual-EN/2.query-language/1.data-types/data-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ The string type is used to store a sequence of characters (text). The literal co
## Timestamp

- The supported range of timestamp type is '1970-01-01 00:00:01' UTC to '2262-04-11 23:47:16' UTC
- Timestamp is measured in units of seconds
- Supported data inserting methods
- call function now()
- Time string, for example: "2019-10-01 10:00:00"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Insert Edge Syntax

```
INSERT EDGE edge_name ( <prop_name_list> ) {VALUES | VALUE}
INSERT EDGE edge_name ( <prop_name_list> ) {VALUES | VALUE}
<src_vid> -> <dst_vid> : ( <prop_value_list> )
[, <src_vid> -> <dst_vid> : ( <prop_value_list> )]
Expand All @@ -18,9 +18,9 @@ INSERT EDGE edge_name ( <prop_name_list> ) {VALUES | VALUE}
* `<prop_name_list>` is the property name list as the given `<edge_name>`.
* `<prop_value_list>` must provide the value list according to `<prop_name_list>`. If no value matches the type, an error will be returned.

>No default value is given in this release.
> No default value is given in this release.
### Examples
## Examples

```
# CREATE EDGE e1() -- create edge t1 with empty property or default values
Expand All @@ -30,18 +30,16 @@ INSERT EDGE e1 () VALUES 10->11:() -- insert an edge from vertex 10 to vertex
```
# CREATE EDGE e2 (name string, age int) -- create edge e2 with two properties
INSERT EDGE e2 (name, age) VALUES 11->13:("n1", 1) -- insert edge from 11 to 13 with two properties
INSERT EDGE e2 (name, age) VALUES \
INSERT EDGE e2 (name, age) VALUES \
12->13:("n1", 1), 13->14("n2", 2) -- insert two edges
INSERT EDGE e2 (name, age) VALUES 11->13:("n1", "a13") -- WRONG. "a13" is not int
INSERT EDGE e2 (name, age) VALUES 11->13:("n1", "a13") -- ERROR. "a13" is not int
```


An edge can be inserted/wrote multiple times. Only the last write values can be read.
An edge can be inserted/wrote multiple times. Only the last written values can be read.

```
-- insert edge with the new version of values. 
INSERT EDGE e2 (name, age) VALUES 11->13:("n1", 12)
INSERT EDGE e2 (name, age) VALUES 11->13:("n1", 13)
-- insert edge with the new values.
INSERT EDGE e2 (name, age) VALUES 11->13:("n1", 12)
INSERT EDGE e2 (name, age) VALUES 11->13:("n1", 13)
INSERT EDGE e2 (name, age) VALUES 11->13:("n1", 14) -- the last version can be read
```

Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ prop_value_list:
[prop_value [, prop_value] ...]
```

INSERT VERTEX statements inserts one vertex into Nebula.
INSERT VERTEX statement inserts one vertex into Nebula.

* `tag_name` denotes the `tag` (vertex type), which must be created before `INSERT VERTEX`.
* `prop_name_list` is the property name list as the given `tag_name`.
* `prop_value_list` must provide the value list according to `prop_name_list`. If any value doesn't match its type, an error will be returned.
* `prop_value_list` must provide the value list according to `prop_name_list`. If no value matches the type, an error will be returned.

> No default value is given in this release.
### Examples
## Examples

```
# CREATE TAG t1() -- create tag t1 with empty property
Expand All @@ -27,8 +28,8 @@ INSERT VERTEX t1 () VALUES 10:() -- insert a vertex with vid 100 and empty pr

```
# CREATE TAG t2 (name string, age int) -- create tag t2 with two properties
INSERT VERTEX t2 (name, age) VALUES 11:("n1", 12) -- insert vertex 11 with the properties
INSERT VERTEX t2 (name, age) VALUES 12:("n1", "a13") -- WRONG. "a13" is not int
INSERT VERTEX t2 (name, age) VALUES 11:("n1", 12) -- insert vertex 11 with two properties
INSERT VERTEX t2 (name, age) VALUES 12:("n1", "a13") -- ERROR. "a13" is not int
```

```
Expand All @@ -37,10 +38,10 @@ INSERT VERTEX t2 (name, age) VALUES 12:("n1", "a13") -- WRONG. "a13" is not int
INSERT VERTEX t1 (i1), t2(s2) VALUES 21: (321, "hello") -- insert vertex 21 with two tags.
```

A vertex can be inserted/wrote multiple times. Only the last write values can be read.
A vertex can be inserted/wrote multiple times. Only the last written values can be read.

```
-- insert vertex 11 with the new version of values.
-- insert vertex 11 with the new values.
INSERT VERTEX t2 (name, age) VALUES 11:("n2", 13)
INSERT VERTEX t2 (name, age) VALUES 11:("n3", 14)
INSERT VERTEX t2 (name, age) VALUES 11:("n4", 15)  -- the last version can be read
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ Nebula supports `UPDATE` properties of a vertex or an edge, as well as CAS opera
UPDATE VERTEX $vid SET $update_columns WHEN $condition YIELD $columns
```

**NOTE:** `WHEN` and `YIELD` are optional. 
**NOTE:** `WHEN` and `YIELD` are optional.

- `$vid` is the id of the vertex to be updated.
- `$update_columns` is the properties of the vertex to be updated, for example, `tag1.col1 = $^.tag2.col2 + 1` means to update `tag1.col1` to `tag2.col2+1`.

**NOTE:**  `$^` indicates vertex to be updated
**NOTE:**  `$^` indicates vertex to be updated
- `$condition` is some constraints, only when met, `UPDATE` will run successfully and expression operations are supported.
- `$columns` is the columns to be returned, `YIELD` returns the latest updated values.

Expand All @@ -35,7 +35,7 @@ UPDATE EDGE $edge SET $update_columns WHEN $condition YIELD $columns

- `$edge` is the edge to be updated, the syntax is `$src->$dst@$rank OF $type`.
- `$update_columns` is the properties of the edge to be updated.
- `$condition` is some constraints, only when met, `UPDATE` will run successfully and expression operations are supported.
- `$condition` is some constraints, only when met, `UPDATE` will run successfully and expression operations are supported.
- `$columns` is the columns to be returned, `YIELD` returns the latest updated values.

Consider the following example:
Expand All @@ -44,4 +44,4 @@ Consider the following example:
nebula> UPDATE EDGE 200 -> 101@0 OF select SET grade = select.grade + 1, year = 2000 WHEN select.grade > 4 && $^.student.age > 15 YIELD $^.student.name AS Name, select.grade AS Grade, select.year AS Year
```

> **NOTE:** The constraints are the source student's age, the returns are properties of the vertex and edge.
> **NOTE:** The constraints are the source student's age, the returns are properties of the vertex and edge.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ Currently, the `WHERE` statement only applies to the `GO` statement.
WHERE (expression [ AND | OR expression ...])
```

Usually, the expression is for vertex or edge properties.
Usually, `WHERE` is a set of logical combination that filter vertex or edge properties.

>As syntax sugar, you can freely choose to use both `AND` and `&&`. They are both boolean logical and. So do `OR` and `||`.
> As syntactic sugar, you can freely choose to use both `AND` and `&&`. They are both boolean logical and. So do `OR` and `||`.
### Examples
## Examples

```
/* GO FROM 201 OVER like */ -- Apply in a GO statement
Expand All @@ -22,5 +22,3 @@ WHERE ((e3.prop3 < 0.5) OR ($^.v4.prop4 != "hello")) AND $$.v5.prop5 == "world"
WHERE 1 == 1 OR TRUE --always TRUE
```

### Reference
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ YIELD
[, <col_name> [AS <col_alias>] ...]
```

`YIELD` is commonly used to return results generated with `GO`.
`YIELD` is commonly used to return results generated with `GO` (Refer [GO](go-syntax.md)).

```sql
nebula> GO FROM 201 OVER relations_edge YIELD $$.student.name AS Friend,\
Expand Down Expand Up @@ -91,9 +91,7 @@ nebula> YIELD hash("Tim") % 100
---------------------
```

**Note**

You can not use `YIELD DISTINCT` as a separate statement. This is a syntax error.
**Note**: You can not use `YIELD DISTINCT` as a separate statement. This is a syntax error.

```sql
nebula> YIELD DISTINCT 1 --- syntax error!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ DESCRIBE EDGE <edge_name>

The DESCRIBE keyword is used to obtain information about space, tag, edge structure.

Also notice that DESCRIBE is different from SHOW.
Also notice that DESCRIBE is different from SHOW. Refer [SHOW](show-syntax.md).

## Example

Providing information about space. <!-- As regards information about CREATE SPACE. -->
Obtain information about space.

```SQL
nebula> DESCRIBE SPACE laura_space;
Expand All @@ -23,7 +23,7 @@ nebula> DESCRIBE SPACE laura_space;
-------------------------------------------------------- 
```

Providing information about tag. <!-- As regards information about CREATE TAG. -->
Obtain information about tag.

```SQL
nebula> DESCRIBE TAG player
Expand All @@ -36,7 +36,7 @@ nebula> DESCRIBE TAG player
------------------ 
```

Providing information about edge. <!-- As regards information about CREATE EDGE. -->
Obtain information about edge.

```SQL
nebula> DESCRIBE EDGE serve
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ SHOW {SPACES | TAGS | EDGES | HOSTS}
SHOW CONFIGS [graph|meta|storage]
```

`SHOW SPACES` lists the SPACES on the Nebula Graph cluster. x
`SHOW SPACES` lists the SPACES on the Nebula Graph cluster.

`SHOW TAGS` and `SHOW EDGES` return the defined tags and edge types in the space, respectively.
`SHOW TAGS` and `SHOW EDGES` return the defined tags and edge types in the space, respectively.

`SHOW HOSTS` is to list storage hosts registered by the meta server. There are 6 columns: ip, port, status (online/offline), leader partitions count in all spaces, leader partitions count in each space, total partitions count in all spaces.

For more information about `SHOW VARIABLES [graph|meta|storage]`, please refer to [variable syntax](../../../3.build-develop-and-administration/3.deploy-and-administrations/server-administration/configuration-statements/variables-syntax.md).
For more information about `SHOW CONFIGS [graph|meta|storage]`, please refer to [configs syntax](../../../3.build-develop-and-administration/3.deploy-and-administrations/server-administration/configuration-statements/configs-syntax.md).

## Example

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ nebula> GO FROM 1 OVER edge1
nebula> USE space1;
```

Different from SQL, making a space as the working space prevents you to access the other space. The only way to traverse in a new graph space is to switch by the `USE` statement.
Different from SQL, making a space as the working space prevents you to access other spaces. The only way to traverse in a new graph space is to switch by the `USE` statement.

> SPACES are `FULLY ISOLATED` from each other. Unlike SQL, which allows you to select two tables from different databases in one statement, in Nebula, you can only touch one space at a time.
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@ FIND SHORTEST | ALL PATH FROM <vertex_id_list> TO <vertex_id_list> OVER <edge_ty

`ALL` is the keyword to find all path.

`<vertex_id_list>::=[vertex_id [, vertex_id]]` is the vertex id list, multiple ids should be separated with a comma, supporting input ```$-```and ```$var```.
`<vertex_id_list>::=[vertex_id [, vertex_id]]` is the vertex id list, multiple ids should be separated with a comma, input ```$-```and ```$var``` are supported.

`<edge_type_list>` is the edge type list, multiple edge types should be separated with a comma, ```*``` can be referred as all edge types.


`<N>` is hop number, the default value is 5.

## Note

- When start and end points are id lists, it means to find the shortest path from any start point to the end point.
- When source and dest vertices are id lists, it means to find the shortest path from any source vertices to the dest vertices.
- There may be cycles when searching all paths.

## Examples
Expand All @@ -46,4 +45,4 @@ nebula> FIND ALL PATH FROM 200 to 201 OVER *
----------------------------------------------------------------------------------------------------
| 200 <like,0> 201 <like,0> 200 <like,0> 201 <like,0> 200 <like,0> 201
----------------------------------------------------------------------------------------------------
```
```

0 comments on commit 43563ba

Please sign in to comment.