Skip to content

Commit

Permalink
change create sentence in nGQL (#906)
Browse files Browse the repository at this point in the history
  • Loading branch information
cooper-lzy authored Nov 10, 2021
1 parent 4f59357 commit 2042135
Show file tree
Hide file tree
Showing 30 changed files with 81 additions and 81 deletions.
6 changes: 3 additions & 3 deletions docs-2.0/20.appendix/0.FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ See [show-stats](../3.ngql-guide/7.general-query-statements/6.show/14.show-stats
1. Create and rebuild the index.

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

2. Use `LOOKUP` or `MATCH`. For example:
Expand Down Expand Up @@ -179,7 +179,7 @@ The graphd process requires `start vids` to begin a graph traversal. The `start
It can also be found from a property index. For example:

```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/20.appendix/identifier-case-sensitivity.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
The following statements would not work because they refer to two different spaces, i.e. `my_space` and `MY_SPACE`:

```ngql
nebula> CREATE SPACE my_space;
nebula> CREATE SPACE IF NOT EXISTS my_space;
nebula> use MY_SPACE;
[ERROR (-8)]: SpaceNotFound:
# my_space and MY_SPACE are two different spaces
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 @@ -56,7 +56,7 @@ CREATE {TAG | EDGE} {<tag_name> | <edge_type>}(<property_name> <data_type>
Example statement:

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

## About openCypher compatibility
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
The following statements will not work because they refer to two different spaces, i.e. `my_space` and `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>
### Examples

```ngql
nebula> CREATE TAG player(name string, age int);
nebula> CREATE TAG IF NOT EXISTS player(name string, age int);
# The following example creates a tag with no properties.
nebula> CREATE TAG no_property(); 
nebula> CREATE TAG IF NOT EXISTS no_property(); 
# The following example creates a tag with a default value.
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);
# In the following example, the TTL of the create_time field is set to be 100 seconds.
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,7 +29,7 @@ DROP TAG [IF EXISTS] <tag_name>;
## Example

```ngql
nebula> CREATE TAG test(p1 string, p2 int);
nebula> CREATE TAG IF NOT EXISTS test(p1 string, p2 int);
nebula> DROP TAG test;
```

Expand Down
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:
## Examples

```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>;
## Example

```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 @@ For example, in the `basketballplayer` data set, some basketball players are als

```ngql
//This example creates the shareholder tag and index.
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();
//This example adds a tag on the vertex.
nebula> INSERT VERTEX shareholder() VALUES "player100":();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ CREATE EDGE [IF NOT EXISTS] <edge_type_name>
### Examples

```ngql
nebula> CREATE EDGE follow(degree int);
nebula> CREATE EDGE IF NOT EXISTS follow(degree int);
# The following example creates an edge type with no properties.
nebula> CREATE EDGE no_property();
nebula> CREATE EDGE IF NOT EXISTS no_property();
# The following example creates an edge type with a default value.
nebula> CREATE EDGE follow_with_default(degree int DEFAULT 20);
nebula> CREATE EDGE IF NOT EXISTS follow_with_default(degree int DEFAULT 20);
# In the following example, the TTL of the p2 field is set to be 100 seconds.
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";
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ DROP EDGE [IF EXISTS] <edge_type_name>
## Example

```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:
## Example

```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 @@ Examples are as follows.

```ngql
# The following examples create tag t1 with no property and inserts vertex "10" with no property.
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);
# In the following example, the insertion fails because "a13" is not 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);
# The following example inserts vertex "21" with two tags.
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);
# In the following example, the insertion fails because the value of p1 cannot be 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" \
In the last query of the preceding examples, since `age` has no default value, when the vertex is created, `age` is `NULL`, and `age = age + 1` does not take effect. But if `age` has a default value, `age = age + 1` will take effect. For example:

```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
# The following example creates edge type e1 with no property and inserts an edge from vertex "10" to vertex "11" with no property.
nebula> CREATE EDGE e1();
nebula> CREATE EDGE IF NOT EXISTS e1();
nebula> INSERT EDGE e1 () VALUES "10"->"11":();
# The following example inserts an edge from vertex "10" to vertex "11" with no property. The edge rank is 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);
# The following example creates edge type e2 with two properties.
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 \
In the last query of the preceding example, since `end_year` has no default value, when the edge is created, `end_year` is `NULL`, and `end_year = end_year + 1` does not take effect. But if `end_year` has a default value, `end_year = end_year + 1` will take effect. For example:

```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 @@ -82,43 +82,43 @@ CREATE {TAG | EDGE} INDEX [IF NOT EXISTS] <index_name> ON {<tag_name> | <edge_na
## Create tag/edge type indexes

```ngql
nebula> CREATE TAG INDEX player_index on player();
nebula> CREATE TAG INDEX IF NOT EXISTS player_index on player();
```

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

After indexing a tag or an edge type, you can use the `LOOKUP` statement to retrieve the VID of all vertices `with the tag`, or `the source vertex ID, destination vertex ID, and ranks` of `all edges with the edge type`. For more information, see [LOOKUP](../7.general-query-statements/5.lookup.md).

## Create single-property indexes

```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));
```

The preceding example creates an index for the `name` property on all vertices carrying the `player` tag. This example creates an index using the first 10 characters of the `name` property.

```ngql
# To index a variable-length string property, you need to specify the index length.
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));
# To index a fixed-length string property, you do not need to specify the index length.
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);
```

## Create composite property indexes

An index on multiple properties on a tag (or an edge type) is called a composite property index.

```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>];
## Examples

```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));
# The following example rebuilds an index and returns the job 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
// This example creates the graph space.
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));
// This example signs in the text service.
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;
// This example creates the tag.
nebula> CREATE TAG player(name string, age int);
nebula> CREATE TAG IF NOT EXISTS player(name string, age int);
// This example creates the native index.
nebula> CREATE TAG INDEX name ON player(name(20));
nebula> CREATE TAG INDEX IF NOT EXISTS name ON player(name(20));
// This example rebuilds the native index.
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 @@ The following graph is used as the sample.
Insert the test data:

```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 @@ For functions about the geography data type, see [Geography functions](../6.func

```ngql
//Create a Tag to allow storing any geography data type.
nebula> CREATE TAG any_shape(geo geography);
nebula> CREATE TAG IF NOT EXISTS any_shape(geo geography);
//Create a Tag to allow storing a point only.
nebula> CREATE TAG only_point(geo geography(point));
nebula> CREATE TAG IF NOT EXISTS only_point(geo geography(point));
//Create a Tag to allow storing a linestring only.
nebula> CREATE TAG only_linestring(geo geography(linestring));
nebula> CREATE TAG IF NOT EXISTS only_linestring(geo geography(linestring));
//Create a Tag to allow storing a polygon only.
nebula> CREATE TAG only_polygon(geo geography(polygon));
nebula> CREATE TAG IF NOT EXISTS only_polygon(geo geography(polygon));
//Create an Edge type to allow storing any geography data type.
nebula> CREATE EDGE any_shape_edge(geo geography);
nebula> CREATE EDGE IF NOT EXISTS any_shape_edge(geo geography);
//Create a vertex to store the geography of a polygon.
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
+---------------------+---------------------+----------------------+---------------------------------+
//Create an index for the geography of the Tag any_shape and run 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 @@ For example:
- Define the data type of the property as a fixed-length string

```ngql
nebula> CREATE TAG t1 (p1 FIXED_STRING(10));
nebula> CREATE TAG IF NOT EXISTS t1 (p1 FIXED_STRING(10));
```
- Define the data type of the property as a variable-length string
```ngql
nebula> CREATE TAG t2 (p2 STRING);
nebula> CREATE TAG IF NOT EXISTS t2 (p2 STRING);
```
When the fixed-length string you try to write exceeds the length limit:
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 @@ -78,7 +78,7 @@ The `TIMESTAMP` data type is used for values that contain both date and time par
1. Create a tag named `date1` with three properties: `DATE`, `TIME`, and `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. Insert a vertex named `test1`.
Expand All @@ -90,7 +90,7 @@ The `TIMESTAMP` data type is used for values that contain both date and time par
3. Return the content of the property `p1` on `test1`.
```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;
+------------+
Expand All @@ -103,7 +103,7 @@ The `TIMESTAMP` data type is used for values that contain both date and time par
4. Create a tag named `school` with the property of `TIMESTAMP`.
```ngql
nebula> CREATE TAG school(name string , found_time timestamp);
nebula> CREATE TAG IF NOT EXISTS school(name string , found_time timestamp);
```
5. Insert a vertex named `DUT` with a found-time timestamp of `"1988-03-01T08:00:00"`.
Expand Down
Loading

0 comments on commit 2042135

Please sign in to comment.