From 93e13b69bf0f402388a9091132c3bc86e966b82d Mon Sep 17 00:00:00 2001 From: Amber1990Zhang <1345783682@qq.com> Date: Thu, 2 Jul 2020 10:51:57 +0800 Subject: [PATCH 1/7] rank --- .../1.overview/1.concepts/1.data-model.md | 4 ++ .../1.overview/1.concepts/2.nGQL-overview.md | 6 +-- .../fetch-syntax.md | 2 +- .../where-syntax.md | 37 ++++++++++++++++++- 4 files changed, 43 insertions(+), 6 deletions(-) diff --git a/docs/manual-EN/1.overview/1.concepts/1.data-model.md b/docs/manual-EN/1.overview/1.concepts/1.data-model.md index d668803a156..9fbdb1f95b3 100644 --- a/docs/manual-EN/1.overview/1.concepts/1.data-model.md +++ b/docs/manual-EN/1.overview/1.concepts/1.data-model.md @@ -47,6 +47,10 @@ Edges are used to connect vertices. Each edge usually represents a relationship Properties are named-value pairs within vertices and edges. In our example graph, we have used the properties `id`, `name` and `age` on **player**, `id` and `name` on **team**, and `likeness` on _**like**_ edge. +## Edge Rank + +Edge rank is an immutable user-assigned 64-bit signed integer. It affects the edge order of the same edge type between two vertices. The edge with a higher rank value comes first. When not specified, the default rank value is zero. + ## Schema In **Nebula Graph**, schema refers to the definition of properties (name, type, etc.). Like `MySQL`, **Nebula Graph** is a **strong typed** database. The name and data type of the properties should be determined before the data is written. diff --git a/docs/manual-EN/1.overview/1.concepts/2.nGQL-overview.md b/docs/manual-EN/1.overview/1.concepts/2.nGQL-overview.md index 82017420b0a..2ae1c3e8932 100644 --- a/docs/manual-EN/1.overview/1.concepts/2.nGQL-overview.md +++ b/docs/manual-EN/1.overview/1.concepts/2.nGQL-overview.md @@ -35,7 +35,7 @@ - **Edge** : A Link between two vertices - Each edge can be uniquely identified by a tuple **** - ***Edge type (ET)*** is a human readable string, internally it will be assigned a 32-bit integer. The edge type decides the property list (schema) on the edge - - ***Edge rank*** is an immutable user-assigned 64-bit signed integer. It affects the edge order between two vertices. The edge with a higher rank value comes first. When not specified, the default rank value is zero. + - ***Edge rank*** is an immutable user-assigned 64-bit signed integer. It affects the edge order of the same edge type between two vertices. The edge with a higher rank value comes first. When not specified, the default rank value is zero. - Each edge can only be of one type - **Path** : A _non-forked_ connection with multiple vertices and edges between them - The length of a path is the number of the edges on the path, which is one less than the number of vertices @@ -159,7 +159,7 @@ The following statement inserts one or more edges **INSERT EDGE** [**NO OVERWRITE**] [()] **VALUES** ()+ -edge\_value ::= -> [@ ] : +edge\_value ::= -> [@ ] : #### Update a Vertex @@ -178,7 +178,7 @@ The following statement updates a vertex The following statement updates an edge -**UPDATE EDGE** -> [@] **OF** +**UPDATE EDGE** -> [@] **OF** **SET** [**WHERE** ] [**YIELD** ] diff --git a/docs/manual-EN/2.query-language/4.statement-syntax/2.data-query-and-manipulation-statements/fetch-syntax.md b/docs/manual-EN/2.query-language/4.statement-syntax/2.data-query-and-manipulation-statements/fetch-syntax.md index 5c3f8f2d8ad..1d1f85ccae7 100644 --- a/docs/manual-EN/2.query-language/4.statement-syntax/2.data-query-and-manipulation-statements/fetch-syntax.md +++ b/docs/manual-EN/2.query-language/4.statement-syntax/2.data-query-and-manipulation-statements/fetch-syntax.md @@ -57,7 +57,7 @@ FETCH PROP ON -> [@] [, -> ...] [YIELD ` -> ` denotes a starting vertex to (->) an ending vertex. Multiple edges are separated by comma(,). -`` specifies the edge weight of the same edge type; it's optional. +`` specifies the edge rank of the same edge type; it's optional. If not specified, the edge ranked 0 is returned by default. `[YIELD [DISTINCT] ]` is the property list returned. diff --git a/docs/manual-EN/2.query-language/4.statement-syntax/2.data-query-and-manipulation-statements/where-syntax.md b/docs/manual-EN/2.query-language/4.statement-syntax/2.data-query-and-manipulation-statements/where-syntax.md index fb6ad2b7c2d..c77e348c6d5 100644 --- a/docs/manual-EN/2.query-language/4.statement-syntax/2.data-query-and-manipulation-statements/where-syntax.md +++ b/docs/manual-EN/2.query-language/4.statement-syntax/2.data-query-and-manipulation-statements/where-syntax.md @@ -1,12 +1,13 @@ # WHERE Syntax -Currently, the `WHERE` statement only applies to the `GO` statement. -Currently, the `WHERE` statement applies to the `GO` and `LOOKUP` statement. Note some `WHERE` filter conditions are not supported in the `LOOKUP` statement. Refer to the [LOOKUP Doc](lookup-syntax.md) for details. +The `WHERE` clause allows you to specify a search condition for the data returned by a query. The following shows the syntax of the WHERE clause: ```ngql WHERE [ AND | OR ...]) ``` +Currently, the `WHERE` statement applies to the `GO` and `LOOKUP` statement. Note some `WHERE` filter conditions are not supported in the `LOOKUP` statement. Refer to the [LOOKUP Doc](lookup-syntax.md) for details. + Usually, `WHERE` is a set of logical combination that filters vertex or edge properties. > As syntactic sugar, logic AND is represented by `AND` or `&&` and logic OR is represented by `OR` or `||`. @@ -54,3 +55,35 @@ nebula> GO FROM 101 OVER follow WHERE 1 == 1 OR TRUE; | 102 | --------------- ``` + +## Filtering Edge Rank with WHERE + +You can filter the edge rank with the `WHERE` clause. For example: + +```ngql +nebula> CREATE SPACE test; +nebula> USE test; +nebula> CREATE EDGE e1(p1 int); +nebula> CREATE TAG person(p1 int); +nebula> INSERT VERTEX person(p1) VALUES 1:(1); +nebula> INSERT VERTEX person(p1) VALUES 2:(2); +nebula> INSERT EDGE e1(p1) VALUES 1->2@0(10); +nebula> INSERT EDGE e1(p1) VALUES 1->2@1(11); +nebula> INSERT EDGE e1(p1) VALUES 1->2@2(12); +nebula> INSERT EDGE e1(p1) VALUES 1->2@3(13); +nebula> INSERT EDGE e1(p1) VALUES 1->2@4(14); +nebula> INSERT EDGE e1(p1) VALUES 1->2@5(15); +nebula> INSERT EDGE e1(p1) VALUES 1->2@6(16); +nebula> GO FROM 1 OVER e1 WHERE e1._rank>2 YIELD e1._src, e1._dst, e1._rank AS Rank, e1.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 | +------------------------------------ +``` From 1b9b6e0d1c810f5dfd6091bc3b352b2a65b1f882 Mon Sep 17 00:00:00 2001 From: Amber1990Zhang <1345783682@qq.com> Date: Fri, 3 Jul 2020 09:50:01 +0800 Subject: [PATCH 2/7] updat rank --- .../1.overview/1.concepts/1.data-model.md | 3 ++- .../1.overview/1.concepts/2.nGQL-overview.md | 14 +++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/docs/manual-EN/1.overview/1.concepts/1.data-model.md b/docs/manual-EN/1.overview/1.concepts/1.data-model.md index 9fbdb1f95b3..f9980a31038 100644 --- a/docs/manual-EN/1.overview/1.concepts/1.data-model.md +++ b/docs/manual-EN/1.overview/1.concepts/1.data-model.md @@ -49,7 +49,8 @@ Properties are named-value pairs within vertices and edges. In our example graph ## Edge Rank -Edge rank is an immutable user-assigned 64-bit signed integer. It affects the edge order of the same edge type between two vertices. The edge with a higher rank value comes first. When not specified, the default rank value is zero. +Edge rank is an immutable user-assigned 64-bit signed integer. It affects the edge order of the same edge type between two vertices. The edge with a higher rank value comes first. When not specified, the default rank value is zero. The current sorting basis is "binary coding order", i.e. 0, 1, 2, ... 9223372036854775807, -9223372036854775807, -9223372036854775806, ..., -1. + ## Schema diff --git a/docs/manual-EN/1.overview/1.concepts/2.nGQL-overview.md b/docs/manual-EN/1.overview/1.concepts/2.nGQL-overview.md index 2ae1c3e8932..3ea0bbcfeac 100644 --- a/docs/manual-EN/1.overview/1.concepts/2.nGQL-overview.md +++ b/docs/manual-EN/1.overview/1.concepts/2.nGQL-overview.md @@ -34,8 +34,8 @@ - Each vertex can associate with multiple **tags** - **Edge** : A Link between two vertices - Each edge can be uniquely identified by a tuple **** - - ***Edge type (ET)*** is a human readable string, internally it will be assigned a 32-bit integer. The edge type decides the property list (schema) on the edge - - ***Edge rank*** is an immutable user-assigned 64-bit signed integer. It affects the edge order of the same edge type between two vertices. The edge with a higher rank value comes first. When not specified, the default rank value is zero. + - ***Edge type (ET)*** is a human readable string, internally it will be assigned a 32-bit integer. The edge type decides the property list (schema) on the edge. + - ***Edge rank*** is an immutable user-assigned 64-bit signed integer. It affects the edge order of the same edge type between two vertices. The edge with a higher rank value comes first. When not specified, the default rank value is zero. The current sorting basis is "binary coding order", i.e. 0, 1, 2, ... 9223372036854775807, -9223372036854775807, -9223372036854775806, ..., -1. - Each edge can only be of one type - **Path** : A _non-forked_ connection with multiple vertices and edges between them - The length of a path is the number of the edges on the path, which is one less than the number of vertices @@ -272,8 +272,8 @@ All property names start with a letter. There are a few system property names st ### Built-in Properties -\_id : Vertex id -\_type : Edge type -\_src : Source ID of the edge -\_dst : Destination ID of the edge -\_rank : Edge rank number +- \_id : Vertex id +- \_type : Edge type +- \_src : Source ID of the edge +- \_dst : Destination ID of the edge +- \_rank : Edge rank number From f5410633ffe89d8e187f24a86089626a8b5804b8 Mon Sep 17 00:00:00 2001 From: Amber1990Zhang <1345783682@qq.com> Date: Fri, 3 Jul 2020 10:00:39 +0800 Subject: [PATCH 3/7] vid coding method --- .../insert-vertex-syntax.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/manual-EN/2.query-language/4.statement-syntax/2.data-query-and-manipulation-statements/insert-vertex-syntax.md b/docs/manual-EN/2.query-language/4.statement-syntax/2.data-query-and-manipulation-statements/insert-vertex-syntax.md index ffb1fd69092..4254d1ff58b 100644 --- a/docs/manual-EN/2.query-language/4.statement-syntax/2.data-query-and-manipulation-statements/insert-vertex-syntax.md +++ b/docs/manual-EN/2.query-language/4.statement-syntax/2.data-query-and-manipulation-statements/insert-vertex-syntax.md @@ -15,6 +15,7 @@ INSERT VERTEX statement inserts one vertex into **Nebula Graph**. * `tag_name` denotes the `tag` (vertex type), which must be created before `INSERT VERTEX`. * `prop_name_list` is the property name list in the given `tag_name`. +* `vid` is the vertex ID. The current sorting basis is "binary coding order", i.e. 0, 1, 2, ... 9223372036854775807, -9223372036854775807, -9223372036854775806, ..., -1. `vid` supports specifying ID manually or using hash to generate. * `prop_value_list` must provide the value list according to the `prop_name_list`. If no value matches the type, an error will be returned. ## Examples From 62e426178b6c613af38f4e5dd3d17ed65d75e859 Mon Sep 17 00:00:00 2001 From: Amber1990Zhang <1345783682@qq.com> Date: Fri, 3 Jul 2020 10:01:55 +0800 Subject: [PATCH 4/7] remove extra space --- docs/manual-EN/1.overview/1.concepts/1.data-model.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/manual-EN/1.overview/1.concepts/1.data-model.md b/docs/manual-EN/1.overview/1.concepts/1.data-model.md index f9980a31038..6e6c246ae10 100644 --- a/docs/manual-EN/1.overview/1.concepts/1.data-model.md +++ b/docs/manual-EN/1.overview/1.concepts/1.data-model.md @@ -51,7 +51,6 @@ Properties are named-value pairs within vertices and edges. In our example graph Edge rank is an immutable user-assigned 64-bit signed integer. It affects the edge order of the same edge type between two vertices. The edge with a higher rank value comes first. When not specified, the default rank value is zero. The current sorting basis is "binary coding order", i.e. 0, 1, 2, ... 9223372036854775807, -9223372036854775807, -9223372036854775806, ..., -1. - ## Schema In **Nebula Graph**, schema refers to the definition of properties (name, type, etc.). Like `MySQL`, **Nebula Graph** is a **strong typed** database. The name and data type of the properties should be determined before the data is written. From 189cedf0695c05894e7ad2e5560c6e5076a21160 Mon Sep 17 00:00:00 2001 From: Amber1990Zhang <1345783682@qq.com> Date: Fri, 3 Jul 2020 10:17:37 +0800 Subject: [PATCH 5/7] fix wum --- .../insert-vertex-syntax.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/manual-EN/2.query-language/4.statement-syntax/2.data-query-and-manipulation-statements/insert-vertex-syntax.md b/docs/manual-EN/2.query-language/4.statement-syntax/2.data-query-and-manipulation-statements/insert-vertex-syntax.md index 4254d1ff58b..84eb70df50a 100644 --- a/docs/manual-EN/2.query-language/4.statement-syntax/2.data-query-and-manipulation-statements/insert-vertex-syntax.md +++ b/docs/manual-EN/2.query-language/4.statement-syntax/2.data-query-and-manipulation-statements/insert-vertex-syntax.md @@ -15,7 +15,8 @@ INSERT VERTEX statement inserts one vertex into **Nebula Graph**. * `tag_name` denotes the `tag` (vertex type), which must be created before `INSERT VERTEX`. * `prop_name_list` is the property name list in the given `tag_name`. -* `vid` is the vertex ID. The current sorting basis is "binary coding order", i.e. 0, 1, 2, ... 9223372036854775807, -9223372036854775807, -9223372036854775806, ..., -1. `vid` supports specifying ID manually or using hash to generate. +* `vid` is the vertex ID. The current sorting basis is "binary coding order", i.e. 0, 1, 2, ... 9223372036854775807, -9223372036854775807, -9223372036854775806, ..., -1. `vid` supports specifying ID manually, or call hash() function to generate. + * `prop_value_list` must provide the value list according to the `prop_name_list`. If no value matches the type, an error will be returned. ## Examples From daae049225cfb026938918953daccd212bf51429 Mon Sep 17 00:00:00 2001 From: Amber1990Zhang <1345783682@qq.com> Date: Fri, 3 Jul 2020 15:31:43 +0800 Subject: [PATCH 6/7] fix hg --- .../where-syntax.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/manual-EN/2.query-language/4.statement-syntax/2.data-query-and-manipulation-statements/where-syntax.md b/docs/manual-EN/2.query-language/4.statement-syntax/2.data-query-and-manipulation-statements/where-syntax.md index c77e348c6d5..5646dc46adf 100644 --- a/docs/manual-EN/2.query-language/4.statement-syntax/2.data-query-and-manipulation-statements/where-syntax.md +++ b/docs/manual-EN/2.query-language/4.statement-syntax/2.data-query-and-manipulation-statements/where-syntax.md @@ -67,13 +67,13 @@ nebula> CREATE EDGE e1(p1 int); nebula> CREATE TAG person(p1 int); nebula> INSERT VERTEX person(p1) VALUES 1:(1); nebula> INSERT VERTEX person(p1) VALUES 2:(2); -nebula> INSERT EDGE e1(p1) VALUES 1->2@0(10); -nebula> INSERT EDGE e1(p1) VALUES 1->2@1(11); -nebula> INSERT EDGE e1(p1) VALUES 1->2@2(12); -nebula> INSERT EDGE e1(p1) VALUES 1->2@3(13); -nebula> INSERT EDGE e1(p1) VALUES 1->2@4(14); -nebula> INSERT EDGE e1(p1) VALUES 1->2@5(15); -nebula> INSERT EDGE e1(p1) VALUES 1->2@6(16); +nebula> INSERT EDGE e1(p1) VALUES 1->2@0:(10); +nebula> INSERT EDGE e1(p1) VALUES 1->2@1:(11); +nebula> INSERT EDGE e1(p1) VALUES 1->2@2:(12); +nebula> INSERT EDGE e1(p1) VALUES 1->2@3:(13); +nebula> INSERT EDGE e1(p1) VALUES 1->2@4:(14); +nebula> INSERT EDGE e1(p1) VALUES 1->2@5:(15); +nebula> INSERT EDGE e1(p1) VALUES 1->2@6:(16); nebula> GO FROM 1 OVER e1 WHERE e1._rank>2 YIELD e1._src, e1._dst, e1._rank AS Rank, e1.p1 | ORDER BY Rank DESC; ==================================== | e1._src | e1._dst | Rank | e1.p1 | From a6186f00f7038eaa2d9832bb6513f2b089f9e15a Mon Sep 17 00:00:00 2001 From: Amber1990Zhang <1345783682@qq.com> Date: Mon, 6 Jul 2020 15:16:40 +0800 Subject: [PATCH 7/7] fix doodle --- docs/manual-EN/1.overview/1.concepts/1.data-model.md | 2 +- docs/manual-EN/1.overview/1.concepts/2.nGQL-overview.md | 2 +- .../insert-vertex-syntax.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/manual-EN/1.overview/1.concepts/1.data-model.md b/docs/manual-EN/1.overview/1.concepts/1.data-model.md index 6e6c246ae10..3fa9c995a1d 100644 --- a/docs/manual-EN/1.overview/1.concepts/1.data-model.md +++ b/docs/manual-EN/1.overview/1.concepts/1.data-model.md @@ -49,7 +49,7 @@ Properties are named-value pairs within vertices and edges. In our example graph ## Edge Rank -Edge rank is an immutable user-assigned 64-bit signed integer. It affects the edge order of the same edge type between two vertices. The edge with a higher rank value comes first. When not specified, the default rank value is zero. The current sorting basis is "binary coding order", i.e. 0, 1, 2, ... 9223372036854775807, -9223372036854775807, -9223372036854775806, ..., -1. +Edge rank is an immutable user-assigned 64-bit signed integer. It affects the edge order of the same edge type between two vertices. The edge with a higher rank value comes first. When not specified, the default rank value is zero. The current sorting basis is "binary coding order", i.e. 0, 1, 2, ... 9223372036854775807, -9223372036854775808, -9223372036854775807, ..., -1. ## Schema diff --git a/docs/manual-EN/1.overview/1.concepts/2.nGQL-overview.md b/docs/manual-EN/1.overview/1.concepts/2.nGQL-overview.md index 3ea0bbcfeac..0f7fd9a9565 100644 --- a/docs/manual-EN/1.overview/1.concepts/2.nGQL-overview.md +++ b/docs/manual-EN/1.overview/1.concepts/2.nGQL-overview.md @@ -35,7 +35,7 @@ - **Edge** : A Link between two vertices - Each edge can be uniquely identified by a tuple **** - ***Edge type (ET)*** is a human readable string, internally it will be assigned a 32-bit integer. The edge type decides the property list (schema) on the edge. - - ***Edge rank*** is an immutable user-assigned 64-bit signed integer. It affects the edge order of the same edge type between two vertices. The edge with a higher rank value comes first. When not specified, the default rank value is zero. The current sorting basis is "binary coding order", i.e. 0, 1, 2, ... 9223372036854775807, -9223372036854775807, -9223372036854775806, ..., -1. + - ***Edge rank*** is an immutable user-assigned 64-bit signed integer. It affects the edge order of the same edge type between two vertices. The edge with a higher rank value comes first. When not specified, the default rank value is zero. The current sorting basis is "binary coding order", i.e. 0, 1, 2, ... 9223372036854775807, -9223372036854775808, -9223372036854775807, ..., -1. - Each edge can only be of one type - **Path** : A _non-forked_ connection with multiple vertices and edges between them - The length of a path is the number of the edges on the path, which is one less than the number of vertices diff --git a/docs/manual-EN/2.query-language/4.statement-syntax/2.data-query-and-manipulation-statements/insert-vertex-syntax.md b/docs/manual-EN/2.query-language/4.statement-syntax/2.data-query-and-manipulation-statements/insert-vertex-syntax.md index 84eb70df50a..7f4da03746c 100644 --- a/docs/manual-EN/2.query-language/4.statement-syntax/2.data-query-and-manipulation-statements/insert-vertex-syntax.md +++ b/docs/manual-EN/2.query-language/4.statement-syntax/2.data-query-and-manipulation-statements/insert-vertex-syntax.md @@ -15,7 +15,7 @@ INSERT VERTEX statement inserts one vertex into **Nebula Graph**. * `tag_name` denotes the `tag` (vertex type), which must be created before `INSERT VERTEX`. * `prop_name_list` is the property name list in the given `tag_name`. -* `vid` is the vertex ID. The current sorting basis is "binary coding order", i.e. 0, 1, 2, ... 9223372036854775807, -9223372036854775807, -9223372036854775806, ..., -1. `vid` supports specifying ID manually, or call hash() function to generate. +* `vid` is the vertex ID. The current sorting basis is "binary coding order", i.e. 0, 1, 2, ... 9223372036854775807, -9223372036854775808, -9223372036854775807, ..., -1. `vid` supports specifying ID manually, or call hash() function to generate. * `prop_value_list` must provide the value list according to the `prop_name_list`. If no value matches the type, an error will be returned.