Skip to content

Commit

Permalink
change create sentence in nGQL (#1198)
Browse files Browse the repository at this point in the history
  • Loading branch information
cooper-lzy authored Nov 10, 2021
1 parent f20548d commit 917d8e7
Show file tree
Hide file tree
Showing 29 changed files with 77 additions and 77 deletions.
4 changes: 2 additions & 2 deletions docs-2.0/20.appendix/0.FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ Storage 服务使用 Raft 协议(多数表决),为保证可用性,要求
1. 建立并重建索引。

```ngql
> CREATE TAG INDEX i_player ON player();
> CREATE TAG INDEX IF NOT EXISTS i_player ON player();
> REBUILD TAG INDEX i_player;
```

Expand Down Expand Up @@ -183,7 +183,7 @@ nGQL 没有该功能。
或者通过一个属性索引来得到,例如:

```ngql
# CREATE TAG INDEX i_player ON player(name(20));
# CREATE TAG INDEX IF NOT EXISTS i_player ON player(name(20));
# REBUILD TAG INDEX i_player;
> LOOKUP ON player WHERE player.name == "abc" | ... YIELD ...
Expand Down
2 changes: 1 addition & 1 deletion docs-2.0/3.ngql-guide/1.nGQL-overview/1.overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ CREATE {TAG | EDGE} {<tag_name> | <edge_type>}(<property_name> <data_type>
示例语句:

```ngql
nebula> CREATE TAG player(name string, age int);
nebula> CREATE TAG IF NOT EXISTS player(name string, age int);
```

## 关于openCypher兼容性
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
以下语句会出现错误,因为`my_space``MY_SPACE`是两个不同的图空间。

```ngql
nebula> CREATE SPACE my_space (vid_type=FIXED_STRING(30));
nebula> CREATE SPACE IF NOT EXISTS my_space (vid_type=FIXED_STRING(30));
nebula> use MY_SPACE;
[ERROR (-8)]: SpaceNotFound:
```
Expand Down
8 changes: 4 additions & 4 deletions docs-2.0/3.ngql-guide/10.tag-statements/1.create-tag.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ CREATE TAG [IF NOT EXISTS] <tag_name>
## 示例

```ngql
nebula> CREATE TAG player(name string, age int);
nebula> CREATE TAG IF NOT EXISTS player(name string, age int);
# 创建没有属性的Tag。
nebula> CREATE TAG no_property(); 
nebula> CREATE TAG IF NOT EXISTS no_property(); 
# 创建包含默认值的Tag。
nebula> CREATE TAG player_with_default(name string, age int DEFAULT 20);
nebula> CREATE TAG IF NOT EXISTS player_with_default(name string, age int DEFAULT 20);
# 对字段create_time设置TTL为100秒。
nebula> CREATE TAG woman(name string, age int, \
nebula> CREATE TAG IF NOT EXISTS woman(name string, age int, \
married bool, salary double, create_time timestamp) \
TTL_DURATION = 100, TTL_COL = "create_time";
```
Expand Down
2 changes: 1 addition & 1 deletion docs-2.0/3.ngql-guide/10.tag-statements/2.drop-tag.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ DROP TAG [IF EXISTS] <tag_name>;
## 示例

```ngql
nebula> CREATE TAG test(p1 string, p2 int);
nebula> CREATE TAG IF NOT EXISTS test(p1 string, p2 int);
nebula> DROP TAG test;
```
2 changes: 1 addition & 1 deletion docs-2.0/3.ngql-guide/10.tag-statements/3.alter-tag.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ttl_definition:
## 示例

```ngql
nebula> CREATE TAG t1 (p1 string, p2 int);
nebula> CREATE TAG IF NOT EXISTS t1 (p1 string, p2 int);
nebula> ALTER TAG t1 ADD (p3 int, p4 string);
nebula> ALTER TAG t1 TTL_DURATION = 2, TTL_COL = "p2";
nebula> ALTER TAG t1 COMMENT = 'test1';
Expand Down
4 changes: 2 additions & 2 deletions docs-2.0/3.ngql-guide/10.tag-statements/6.delete-tag.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ DELETE TAG <tag_name_list> FROM <VID>;
## 示例

```ngql
nebula> CREATE TAG test1(p1 string, p2 int);
nebula> CREATE TAG test2(p3 string, p4 int);
nebula> CREATE TAG IF NOT EXISTS test1(p1 string, p2 int);
nebula> CREATE TAG IF NOT EXISTS test2(p3 string, p4 int);
nebula> INSERT VERTEX test1(p1, p2),test2(p3, p4) VALUES "test":("123", 1, "456", 2);
nebula> FETCH PROP ON * "test";
+------------------------------------------------------------+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

```ngql
//创建股东Tag和索引
nebula> CREATE TAG shareholder();
nebula> CREATE TAG INDEX shareholder_tag on shareholder();
nebula> CREATE TAG IF NOT EXISTS shareholder();
nebula> CREATE TAG INDEX IF NOT EXISTS shareholder_tag on shareholder();
//为点添加Tag
nebula> INSERT VERTEX shareholder() VALUES "player100":();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ CREATE EDGE [IF NOT EXISTS] <edge_type_name>
### 示例

```ngql
nebula> CREATE EDGE follow(degree int);
nebula> CREATE EDGE IF NOT EXISTS follow(degree int);
# 创建没有属性的Edge type。
nebula> CREATE EDGE no_property();
nebula> CREATE EDGE IF NOT EXISTS no_property();
# 创建包含默认值的Edge type。
nebula> CREATE EDGE follow_with_default(degree int DEFAULT 20);
nebula> CREATE EDGE IF NOT EXISTS follow_with_default(degree int DEFAULT 20);
# 对字段p2设置TTL为100秒。
nebula> CREATE EDGE e1(p1 string, p2 int, p3 timestamp) \
nebula> CREATE EDGE IF NOT EXISTS e1(p1 string, p2 int, p3 timestamp) \
TTL_DURATION = 100, TTL_COL = "p2";
```
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ DROP EDGE [IF EXISTS] <edge_type_name>
## 示例

```ngql
nebula> CREATE EDGE e1(p1 string, p2 int);
nebula> CREATE EDGE IF NOT EXISTS e1(p1 string, p2 int);
nebula> DROP EDGE e1;
```
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ttl_definition:
## 示例

```ngql
nebula> CREATE EDGE e1(p1 string, p2 int);
nebula> CREATE EDGE IF NOT EXISTS e1(p1 string, p2 int);
nebula> ALTER EDGE e1 ADD (p3 int, p4 string);
nebula> ALTER EDGE e1 TTL_DURATION = 2, TTL_COL = "p2";
nebula> ALTER EDGE e1 COMMENT = 'edge1';
Expand Down
10 changes: 5 additions & 5 deletions docs-2.0/3.ngql-guide/12.vertex-statements/1.insert-vertex.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ prop_value_list:

```ngql
# 插入不包含属性的点。
nebula> CREATE TAG t1();
nebula> CREATE TAG IF NOT EXISTS t1();
nebula> INSERT VERTEX t1() VALUE "10":();
```

```ngql
nebula> CREATE TAG t2 (name string, age int);
nebula> CREATE TAG IF NOT EXISTS t2 (name string, age int);
nebula> INSERT VERTEX t2 (name, age) VALUES "11":("n1", 12);
# 创建失败,因为"a13"不是int类型。
Expand All @@ -64,8 +64,8 @@ nebula> INSERT VERTEX t2 (name, age) VALUES "13":("n3", 12), "14":("n4", 8);
```

```ngql
nebula> CREATE TAG t3(p1 int);
nebula> CREATE TAG t4(p2 string);
nebula> CREATE TAG IF NOT EXISTS t3(p1 int);
nebula> CREATE TAG IF NOT EXISTS t4(p2 string);
# 一次插入两个Tag的属性到同一个点。
nebula> INSERT VERTEX t3 (p1), t4(p2) VALUES "21": (321, "hello");
Expand All @@ -87,7 +87,7 @@ nebula> FETCH PROP ON t2 "11";
```

```ngql
nebula> CREATE TAG t5(p1 fixed_string(5) NOT NULL, p2 int, p3 int DEFAULT NULL);
nebula> CREATE TAG IF NOT EXISTS t5(p1 fixed_string(5) NOT NULL, p2 int, p3 int DEFAULT NULL);
nebula> INSERT VERTEX t5(p1, p2, p3) VALUES "001":("Abe", 2, 3);
# 插入失败,因为属性p1不能为NULL。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ nebula> UPSERT VERTEX ON player "player668" \
上面最后一个示例中,因为`age`没有默认值,插入点时,`age`默认值为`NULL`,执行`age = age + 1`后仍为`NULL`。如果`age`有默认值,则`age = age + 1`可以正常执行,例如:

```ngql
nebula> CREATE TAG player_with_default(name string, age int DEFAULT 20);
nebula> CREATE TAG IF NOT EXISTS player_with_default(name string, age int DEFAULT 20);
Execution succeeded
nebula> UPSERT VERTEX ON player_with_default "player101" \
Expand Down
4 changes: 2 additions & 2 deletions docs-2.0/3.ngql-guide/13.edge-statements/1.insert-edge.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ INSERT EDGE [IF NOT EXISTS] <edge_type> ( <prop_name_list> ) {VALUES | VALUE}

```ngql
# 插入不包含属性的边。
nebula> CREATE EDGE e1();
nebula> CREATE EDGE IF NOT EXISTS e1();
nebula> INSERT EDGE e1 () VALUES "10"->"11":();
# 插入rank为1的边。
nebula> INSERT EDGE e1 () VALUES "10"->"11"@1:();
```

```ngql
nebula> CREATE EDGE e2 (name string, age int);
nebula> CREATE EDGE IF NOT EXISTS e2 (name string, age int);
nebula> INSERT EDGE e2 (name, age) VALUES "11"->"13":("n1", 1);
# 一次插入2条边。
Expand Down
2 changes: 1 addition & 1 deletion docs-2.0/3.ngql-guide/13.edge-statements/3.upsert-edge.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ nebula> UPSERT EDGE on serve \
上面最后一个示例中,因为`end_year`没有默认值,插入边时,`end_year`默认值为`NULL`,执行`end_year = end_year + 1`后仍为`NULL`。如果`end_year`有默认值,则`end_year = end_year + 1`可以正常执行,例如:

```ngql
nebula> CREATE EDGE serve_with_default(start_year int, end_year int DEFAULT 2010);
nebula> CREATE EDGE IF NOT EXISTS serve_with_default(start_year int, end_year int DEFAULT 2010);
Execution succeeded
nebula> UPSERT EDGE on serve_with_default \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,31 +94,31 @@ nebula> CREATE EDGE INDEX follow_index on follow();
## 创建单属性索引

```ngql
nebula> CREATE TAG INDEX player_index_0 on player(name(10));
nebula> CREATE TAG INDEX IF NOT EXISTS player_index_0 on player(name(10));
```

上述示例是为所有包含Tag`player`的点创建属性`name`的索引,索引长度为10。即只使用属性`name`的前10个字符来创建索引。

```ngql
# 变长字符串需要指定索引长度。
nebula> CREATE TAG var_string(p1 string);
nebula> CREATE TAG INDEX var ON var_string(p1(10));
nebula> CREATE TAG IF NOT EXISTS var_string(p1 string);
nebula> CREATE TAG INDEX IF NOT EXISTS var ON var_string(p1(10));
# 定长字符串不需要指定索引长度。
nebula> CREATE TAG fix_string(p1 FIXED_STRING(10));
nebula> CREATE TAG INDEX fix ON fix_string(p1);
nebula> CREATE TAG IF NOT EXISTS fix_string(p1 FIXED_STRING(10));
nebula> CREATE TAG INDEX IF NOT EXISTS fix ON fix_string(p1);
```

```ngql
nebula> CREATE EDGE INDEX follow_index_0 on follow(degree);
nebula> CREATE EDGE INDEX IF NOT EXISTS follow_index_0 on follow(degree);
```

## 创建复合属性索引

`复合属性索引`用于查找一个Tag(或者Edge type)中的多个属性(的组合)。

```ngql
nebula> CREATE TAG INDEX player_index_1 on player(name(10), age);
nebula> CREATE TAG INDEX IF NOT EXISTS player_index_1 on player(name(10), age);
```

!!! caution
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ REBUILD {TAG | EDGE} INDEX [<index_name_list>];
## 示例

```ngql
nebula> CREATE TAG person(name string, age int, gender string, email string);
nebula> CREATE TAG INDEX single_person_index ON person(name(10));
nebula> CREATE TAG IF NOT EXISTS person(name string, age int, gender string, email string);
nebula> CREATE TAG INDEX IF NOT EXISTS single_person_index ON person(name(10));
# 重建索引,返回任务ID。
nebula> REBUILD TAG INDEX single_person_index;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ LOOKUP ON {<tag> | <edge_type>} WHERE <expression> [YIELD <return_list>];

```ngql
//创建图空间。
nebula> CREATE SPACE basketballplayer (partition_num=3,replica_factor=1, vid_type=fixed_string(30));
nebula> CREATE SPACE IF NOT EXISTS basketballplayer (partition_num=3,replica_factor=1, vid_type=fixed_string(30));
//登录文本搜索客户端。
nebula> SIGN IN TEXT SERVICE (127.0.0.1:9200);
Expand All @@ -86,10 +86,10 @@ nebula> USE basketballplayer;
nebula> ADD LISTENER ELASTICSEARCH 192.168.8.5:9789;
//创建Tag。
nebula> CREATE TAG player(name string, age int);
nebula> CREATE TAG IF NOT EXISTS player(name string, age int);
//创建原生索引。
nebula> CREATE TAG INDEX name ON player(name(20));
nebula> CREATE TAG INDEX IF NOT EXISTS name ON player(name(20));
//重建原生索引。
nebula> REBUILD TAG INDEX;
Expand Down
10 changes: 5 additions & 5 deletions docs-2.0/3.ngql-guide/16.subgraph-and-path/1.get-subgraph.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ GET SUBGRAPH [WITH PROP] [<step_count> STEPS] FROM {<vid>, <vid>...}
插入测试数据:

```ngql
nebula> CREATE SPACE subgraph(partition_num=15, replica_factor=1, vid_type=fixed_string(30));
nebula> CREATE SPACE IF NOT EXISTS subgraph(partition_num=15, replica_factor=1, vid_type=fixed_string(30));
nebula> USE subgraph;
nebula> CREATE TAG player(name string, age int);
nebula> CREATE TAG team(name string);
nebula> CREATE EDGE follow(degree int);
nebula> CREATE EDGE serve(start_year int, end_year int);
nebula> CREATE TAG IF NOT EXISTS player(name string, age int);
nebula> CREATE TAG IF NOT EXISTS team(name string);
nebula> CREATE EDGE IF NOT EXISTS follow(degree int);
nebula> CREATE EDGE IF NOT EXISTS serve(start_year int, end_year int);
nebula> INSERT VERTEX player(name, age) VALUES "player100":("Tim Duncan", 42);
nebula> INSERT VERTEX player(name, age) VALUES "player101":("Tony Parker", 36);
nebula> INSERT VERTEX player(name, age) VALUES "player102":("LaMarcus Aldridge", 33);
Expand Down
12 changes: 6 additions & 6 deletions docs-2.0/3.ngql-guide/3.data-types/10.geography.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ geo相关函数请参见[geo函数](../6.functions-and-expressions/14.geo.md)。

```ngql
//创建Tag,允许存储任意形状地理位置数据类型。
nebula> CREATE TAG any_shape(geo geography);
nebula> CREATE TAG IF NOT EXISTS any_shape(geo geography);
//创建Tag,只允许存储点形状地理位置数据类型。
nebula> CREATE TAG only_point(geo geography(point));
nebula> CREATE TAG IF NOT EXISTS only_point(geo geography(point));
//创建Tag,只允许存储线段形状地理位置数据类型。
nebula> CREATE TAG only_linestring(geo geography(linestring));
nebula> CREATE TAG IF NOT EXISTS only_linestring(geo geography(linestring));
//创建Tag,只允许存储多边形形状地理位置数据类型。
nebula> CREATE TAG only_polygon(geo geography(polygon));
nebula> CREATE TAG IF NOT EXISTS only_polygon(geo geography(polygon));
//创建Edge type,允许存储任意形状地理位置数据类型。
nebula> CREATE EDGE any_shape_edge(geo geography);
nebula> CREATE EDGE IF NOT EXISTS any_shape_edge(geo geography);
//创建存储多边形地理位置的点。
nebula> INSERT VERTEX any_shape(geo) VALUES "103":(ST_GeogFromText("POLYGON((0 1, 1 2, 2 3, 0 1))"));
Expand All @@ -65,7 +65,7 @@ nebula> FETCH PROP ON any_shape_edge "201"->"302" YIELD ST_ASText(any_shape_edge
+---------------------+---------------------+----------------------+---------------------------------+
//为geo属性创建索引并使用LOOKUP查询。
nebula> CREATE TAG INDEX any_shape_geo_index ON any_shape(geo);
nebula> CREATE TAG INDEX IF NOT EXISTS any_shape_geo_index ON any_shape(geo);
nebula> REBUILD TAG INDEX any_shape_geo_index;
nebula> LOOKUP ON any_shape YIELD ST_ASText(any_shape.geo);
+----------+-------------------------------------------------+
Expand Down
4 changes: 2 additions & 2 deletions docs-2.0/3.ngql-guide/3.data-types/3.string.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ nGQL支持以如下方式使用字符串:
- 将属性值的类型定义为定长字符串

```ngql
nebula> CREATE TAG t1 (p1 FIXED_STRING(10));
nebula> CREATE TAG IF NOT EXISTS t1 (p1 FIXED_STRING(10));
```

- 将属性值的类型定义为变长字符串

```ngql
nebula> CREATE TAG t2 (p2 STRING);
nebula> CREATE TAG IF NOT EXISTS t2 (p2 STRING);
```

如果尝试写入的定长字符串超出长度限制:
Expand Down
6 changes: 3 additions & 3 deletions docs-2.0/3.ngql-guide/3.data-types/4.date-and-time.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
1. 创建Tag,名称为`date1`,包含`DATE``TIME``DATETIME`三种类型。

```ngql
nebula> CREATE TAG date1(p1 date, p2 time, p3 datetime);
nebula> CREATE TAG IF NOT EXISTS date1(p1 date, p2 time, p3 datetime);
```

2. 插入点,名称为`test1`
Expand All @@ -89,7 +89,7 @@
3. 获取`test1`的属性`p1`的月份。

```ngql
nebula> CREATE TAG INDEX date1_index ON date1(p1);
nebula> CREATE TAG INDEX IF NOT EXISTS date1_index ON date1(p1);
nebula> REBUILD TAG INDEX date1_index;
nebula> MATCH (v:date1) RETURN v.p1.month;
+------------+
Expand All @@ -102,7 +102,7 @@
4. 创建Tag,名称为`school`,包含`TIMESTAMP`类型。

```ngql
nebula> CREATE TAG school(name string , found_time timestamp);
nebula> CREATE TAG IF NOT EXISTS school(name string , found_time timestamp);
```

5. 插入点,名称为`DUT`,存储时间为`"1988-03-01T08:00:00"`
Expand Down
4 changes: 2 additions & 2 deletions docs-2.0/3.ngql-guide/3.data-types/5.null.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Nebula Graph中,对NULL的操作以及返回结果不兼容openCypher。
创建Tag,名称为`player`,指定属性`name``NOT NULL`

```ngql
nebula> CREATE TAG player(name string NOT NULL, age int);
nebula> CREATE TAG IF NOT EXISTS player(name string NOT NULL, age int);
```

使用`SHOW`命令查看创建Tag语句,属性`name``NOT NULL`,属性`age`为默认的`NULL`
Expand Down Expand Up @@ -65,7 +65,7 @@ nebula> INSERT VERTEX player(name, age) VALUES "Kobe":("Kobe",null);
创建Tag,名称为`player`,指定属性`age``NOT NULL`,并设置默认值`18`

```ngql
nebula> CREATE TAG player(name string, age int NOT NULL DEFAULT 18);
nebula> CREATE TAG IF NOT EXISTS player(name string, age int NOT NULL DEFAULT 18);
```

插入点`Kobe`,只设置属性`name`
Expand Down
4 changes: 2 additions & 2 deletions docs-2.0/3.ngql-guide/7.general-query-statements/2.match.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ MATCH <pattern> [<WHERE clause>] RETURN <output>;

```ngql
# 在Tag player的name属性和Edge type follow上创建索引。
nebula> CREATE TAG INDEX name ON player(name(20));
nebula> CREATE EDGE INDEX follow_index on follow();
nebula> CREATE TAG INDEX IF NOT EXISTS name ON player(name(20));
nebula> CREATE EDGE INDEX IF NOT EXISTS follow_index on follow();
# 重建索引使其生效。
nebula> REBUILD TAG INDEX name;
Expand Down
Loading

0 comments on commit 917d8e7

Please sign in to comment.