From a9441d5d4804188d4ede68eec04e12da8f8fe841 Mon Sep 17 00:00:00 2001 From: "abby.huang" <78209557+abby-cyber@users.noreply.github.com> Date: Wed, 29 Nov 2023 14:30:13 +0800 Subject: [PATCH] Add statements of fetch all edges by a starting vertex&minor changes (#2380) * add statements of fetch all edges by a starting vertex&minor changes Co-Authored-By: Chris Chen * add example to retrieve all edges Co-Authored-By: Chris Chen * fix line display Co-Authored-By: Chris Chen --------- Co-authored-by: Chris Chen --- .../1.general-query-statements-overview.md | 92 ++++++++-------- .../7.general-query-statements/3.go.md | 20 ++++ .../1.general-query-statements-overview.md | 103 +++++++++--------- .../7.general-query-statements/3.go.md | 20 ++++ 4 files changed, 137 insertions(+), 98 deletions(-) diff --git a/docs-2.0-en/3.ngql-guide/7.general-query-statements/1.general-query-statements-overview.md b/docs-2.0-en/3.ngql-guide/7.general-query-statements/1.general-query-statements-overview.md index ad671779631..cd009f4e3e5 100644 --- a/docs-2.0-en/3.ngql-guide/7.general-query-statements/1.general-query-statements-overview.md +++ b/docs-2.0-en/3.ngql-guide/7.general-query-statements/1.general-query-statements-overview.md @@ -11,7 +11,7 @@ NebulaGraph stores data in the form of vertices and edges. Each vertex can have The primary query statements in NebulaGraph fall into the following categories: - [FETCH PROP ON](#fetch_prop_on) -- [LOOKUP ON](#lookup_on_id) +- [LOOKUP ON](#lookup_on) - [GO](#go) - [MATCH](#match) - [FIND PATH](#find_path) @@ -38,14 +38,14 @@ The primary query statements in NebulaGraph fall into the following categories: ```ngql FETCH PROP ON player "player100" YIELD properties(vertex); - ──┬─── ────┬───── ─────────┬──────── - │ │ ┌───────────┘ - │ │ │ - │ │ └─────── Returns all properties under the player tag of the vertex. - │ │ - │ └───────────────── Retrieves from the vertex "player100". - │ - └─────────────────────────── Retrieves properties under the player tag. + --+--- ----+----- -------+---------- + | | | + | | | + | | +--------- Returns all properties under the player tag of the vertex. + | | + | +----------------- Retrieves from the vertex "player100". + | + +--------------------------- Retrieves properties under the player tag. ``` For more information, see [FETCH PROP ON](4.fetch.md). @@ -65,14 +65,14 @@ For more information, see [FETCH PROP ON](4.fetch.md). ```ngql LOOKUP ON player WHERE player.name == "Tony Parker" YIELD id(vertex); - ──┬─── ──────┬────────────────────────── ──┬────── - │ │ ┌───────────────────┘ - │ │ │ - │ │ └──────────── Returns the VID of the found vertex. - │ │ - │ └─────────────────────── Filtering is based on the value of the property name. - │ - └─────────────────────────────────── Queries based on the player tag. + --+--- ------------------+--------------- ---+------ + | | | + | | | + | | +---- Returns the VID of the retrieved vertex. + | | + | +------------ Filtering is based on the value of the property name. + | + +----------------------------------- Queries based on the player tag. ``` For more information, see [LOOKUP ON](5.lookup.md). @@ -85,22 +85,22 @@ For more information, see [LOOKUP ON](5.lookup.md). **Note:** - Use [property reference symbols](../5.operators/5.property-reference.md) (`$^` and `$$`) to return properties of the starting or target vertices, e.g., `YIELD $^.player.name`. - Use the functions `properties($^)` and `properties($$)` to return all properties of the starting or target vertices. Specify property names in the function to return specific properties, e.g., `YIELD properties($^).name`. -- Use the functions `src(edge)` and `dst(edge)` to return the starting or target vertex ID of an edge, e.g., `YIELD src(edge)`. +- Use the functions `src(edge)` and `dst(edge)` to return the starting or destination vertex ID of an edge, e.g., `YIELD src(edge)`. **Example:** ```ngql GO 3 STEPS FROM "player102" OVER follow YIELD dst(edge); - ───┬─── ───┬─────── ─┬──── ──┬────── - │ │ │ ┌─────────┘ - │ │ │ │ - │ │ │ └── Returns the target vertex of the last edge - │ │ │ - │ │ └────── Traverses out via the edge follow - │ │ - │ └───────────────────── Starts from "player102" - │ - └────────────────────────────────── Traverses 3 steps +-----+--- --+------- -+---- ---+----- + | | | | + | | | | + | | | +--------- Returns the destination vertex of the last hop. + | | | + | | +------ Traverses out via the edge follow. + | | + | +--------------------- Starts from "player102". + | + +---------------------------------- Traverses 3 steps. ``` For more information, see [GO](3.go.md). @@ -141,17 +141,17 @@ For more information, see [MATCH](2.match.md). ```ngql FIND SHORTEST PATH FROM "player102" TO "team204" OVER * YIELD path AS p; - ──┬───── ───────────┬─────────── ───┬─── ────┬──── - │ ┌────────────────┘ │ │ - │ │ ┌──────────────────────────┘ │ - │ │ │ │ - │ │ └Travels outwards via all types of edges └──── Returns the path as 'p' - │ │ - │ └──────From the given starting and target VIDs - │ - │ - │ - └──────────────────Retrieves the shortest path +-------+----- -------+---------------- ---+-- ----+---- + | | | | + | | | | + | | | +---------- Returns the path as 'p'. + | | | + | | +----------- Travels outwards via all types of edges. + | | + | | + | +------------------ From the given starting and target VIDs. + | + +--------------------------- Retrieves the shortest path. ``` For more information, see [FIND PATH](6.find-path.md). @@ -167,13 +167,13 @@ For more information, see [FIND PATH](6.find-path.md). **Example:** ```ngql -GET SUBGRAPH 5 STEPS FROM "player101" YIELD VERTICES AS nodes, EDGES AS relationships; - ───┬─── ─────┬────────── ──────────────────────────┬──────────────── - │ │ │ - │ │ │ - │ └─────── Starts from "player101" └ Returns all vertices and edges - │ - └───────────────── Gets exploration of 5 steps +GET SUBGRAPH 5 STEPS FROM "player101" YIELD VERTICES AS nodes, EDGES AS relationships; + -----+- -----+-------- ------------------------+---------------- + | | | + | | | + | +------- Starts from "player101". +------------ Returns all vertices and edges. + | + +----------------- Gets exploration of 5 steps ``` diff --git a/docs-2.0-en/3.ngql-guide/7.general-query-statements/3.go.md b/docs-2.0-en/3.ngql-guide/7.general-query-statements/3.go.md index e915cd09425..6bc87ffff07 100644 --- a/docs-2.0-en/3.ngql-guide/7.general-query-statements/3.go.md +++ b/docs-2.0-en/3.ngql-guide/7.general-query-statements/3.go.md @@ -152,6 +152,26 @@ nebula> GO FROM "player100", "player102" OVER serve \ +-----------------+------------+---------------------+ ``` +### To query all edges + +Case: To query all edges that are connected to the starting vertex. + +```ngql +# Return all edges that are connected to the player102 vertex. +nebula> GO FROM "player102" OVER * BIDIRECT YIELD edge AS e; ++-----------------------------------------------------------------------+ +| e | ++-----------------------------------------------------------------------+ +| [:follow "player101"->"player102" @0 {degree: 90}] | +| [:follow "player103"->"player102" @0 {degree: 70}] | +| [:follow "player135"->"player102" @0 {degree: 80}] | +| [:follow "player102"->"player100" @0 {degree: 75}] | +| [:follow "player102"->"player101" @0 {degree: 75}] | +| [:serve "player102"->"team203" @0 {end_year: 2015, start_year: 2006}] | +| [:serve "player102"->"team204" @0 {end_year: 2019, start_year: 2015}] | ++-----------------------------------------------------------------------+ +``` + ### To query multiple edge types Case: To query multiple edge types that are connected to the starting vertex. You can specify multiple edge types or the `*` symbol to query multiple edge types. diff --git a/docs-2.0-zh/3.ngql-guide/7.general-query-statements/1.general-query-statements-overview.md b/docs-2.0-zh/3.ngql-guide/7.general-query-statements/1.general-query-statements-overview.md index d1af3b2ba77..a8be785022b 100644 --- a/docs-2.0-zh/3.ngql-guide/7.general-query-statements/1.general-query-statements-overview.md +++ b/docs-2.0-zh/3.ngql-guide/7.general-query-statements/1.general-query-statements-overview.md @@ -11,7 +11,7 @@ {{nebula.name}} 的核心查询语句可分为: - [FETCH PROP ON](#fetch_prop_on) -- [LOOKUP ON](#lookup_on_id) +- [LOOKUP ON](#lookup_on) - [GO](#go) - [MATCH](#match) - [FIND PATH](#find_path) @@ -38,17 +38,17 @@ ```ngql FETCH PROP ON player "player100" YIELD properties(vertex); - ──┬─── ────┬───── ─────────┬──────── - │ │ ┌───────────┘ - │ │ │ - │ │ └─────── 返回点的 player TAG 下所有属性 - │ │ - │ └───────────────── 从 "player100" 这个点获取 - │ - └─────────────────────────── 获取 player 这个 TAG 下的属性 + --+--- ----+----- -------+---------- + | | | + | | | + | | +--------- 返回点的 player TAG 下所有属性 + | | + | +----------------- 从 "player100" 这个点获取 + | + +--------------------------- 获取 player 这个 TAG 下的属性 ``` -更多信息,请参见[FETCH PROP ON](4.fetch.md)。 +更多信息,请参见 [FETCH PROP ON](4.fetch.md)。 ### LOOKUP ON @@ -66,17 +66,17 @@ FETCH PROP ON player "player100" YIELD properties(vertex); ```ngql LOOKUP ON player WHERE player.name == "Tony Parker" YIELD id(vertex); - ──┬─── ──────┬────────────────────────── ──┬────── - │ │ ┌───────────────────┘ - │ │ │ - │ │ └──────────── 返回查到点的 VID - │ │ - │ └─────────────────────── 过滤条件是属性 name 的值 - │ - └─────────────────────────────────── 根据点的 TAG player 查询 + --+--- ------------------+--------------- ---+------ + | | | + | | | + | | +---- 返回查到点的 VID + | | + | +------------ 过滤条件是属性 name 的值 + | + +----------------------------------- 根据点的 TAG player 查询 ``` -更多信息,请参见[LOOKUP ON](5.lookup.md)。 +更多信息,请参见 [LOOKUP ON](5.lookup.md)。 ### GO @@ -94,19 +94,19 @@ LOOKUP ON player WHERE player.name == "Tony Parker" YIELD id(vertex); ```ngql GO 3 STEPS FROM "player102" OVER follow YIELD dst(edge); - ───┬─── ───┬─────── ─┬──── ──┬────── - │ │ │ ┌─────────┘ - │ │ │ │ - │ │ │ └── 返回最后一跳边的终点 - │ │ │ - │ │ └────── 从 follow 这个边[出方向]探索 - │ │ - │ └───────────────────── 起点是 "player102" - │ - └────────────────────────────────── 探索 3 步 +-----+--- --+------- -+---- ---+----- + | | | | + | | | | + | | | +--------- 返回最后一跳边的终点 + | | | + | | +------ 从 follow 这个边的出方向探索 + | | + | +--------------------- 起点是 "player102" + | + +---------------------------------- 探索 3 步 ``` -更多信息,请参见[GO](3.go.md)。 +更多信息,请参见 [GO](3.go.md)。 ### MATCH @@ -133,7 +133,7 @@ MATCH (v:player{name:"Tim Duncan"})--(v2:player) \ RETURN v2.player.name AS Name; ``` -更多信息,请参见[MATCH](2.match.md)。 +更多信息,请参见 [MATCH](2.match.md)。 ### FIND PATH @@ -147,20 +147,20 @@ MATCH (v:player{name:"Tim Duncan"})--(v2:player) \ ```ngql FIND SHORTEST PATH FROM "player102" TO "team204" OVER * YIELD path AS p; - ──┬───── ───────────┬─────────── ───┬─── ────┬──── - │ ┌────────────────┘ │ │ - │ │ ┌──────────────────────────┘ │ - │ │ │ │ - │ │ └───────── 经由所有类型的边出向探索   └──── 返回路径为 p 列 - │ │ - │ └─────────────── 从给定的起点、终点 VID - │ - │ - │ - └─────────────────────────── 查找最短路径 +-------+----- -------+---------------- ---+-- ----+---- + | | | | + | | | | + | | | +---------- 返回路径为 p 列 + | | | + | | +----------- 经由所有类型的边的出方向探索 + | | + | | + | +------------------ 从给定的起点、终点 VID + | + +--------------------------- 查找最短路径 ``` -更多信息,请参见[FIND PATH](6.find-path.md)。 +更多信息,请参见 [FIND PATH](6.find-path.md)。 ### GET SUBGRAPH @@ -173,17 +173,16 @@ FIND SHORTEST PATH FROM "player102" TO "team204" OVER * YIELD path AS p; **示例**: ```ngql -GET SUBGRAPH 5 STEPS FROM "player101" YIELD VERTICES AS nodes, EDGES AS relationships; - ───┬─── ─────┬────────── ──────────────────────────┬──────────────── - │ │ │ - │ │ │ - │ └─────── 从 "player101" 开始出发 └──── 返回所有的点、边 - │ - └───────────────── 获取 5 步的探索 - +GET SUBGRAPH 5 STEPS FROM "player101" YIELD VERTICES AS nodes, EDGES AS relationships; + -----+- -----+-------- ------------------------+---------------- + | | | + | | | + | +------- 从 "player101" 开始出发 +------------ 返回所有的点、边 + | + +----------------- 获取 5 步的探索 ``` -更多信息,请参见[GET SUBGRAPH](7.get-subgraph.md)。 +更多信息,请参见 [GET SUBGRAPH](7.get-subgraph.md)。 ### SHOW diff --git a/docs-2.0-zh/3.ngql-guide/7.general-query-statements/3.go.md b/docs-2.0-zh/3.ngql-guide/7.general-query-statements/3.go.md index f2f6e8c68d1..8189e20a601 100644 --- a/docs-2.0-zh/3.ngql-guide/7.general-query-statements/3.go.md +++ b/docs-2.0-zh/3.ngql-guide/7.general-query-statements/3.go.md @@ -146,6 +146,26 @@ nebula> GO FROM "player100", "player102" OVER serve \ +-----------------+------------+---------------------+ ``` +### 查询所有边 + +场景:查询起始点关联的所有边。 + +```ngql +# 返回 player102 关联的所有边。 +nebula> GO FROM "player102" OVER * BIDIRECT YIELD edge AS e; ++-----------------------------------------------------------------------+ +| e | ++-----------------------------------------------------------------------+ +| [:follow "player101"->"player102" @0 {degree: 90}] | +| [:follow "player103"->"player102" @0 {degree: 70}] | +| [:follow "player135"->"player102" @0 {degree: 80}] | +| [:follow "player102"->"player100" @0 {degree: 75}] | +| [:follow "player102"->"player101" @0 {degree: 75}] | +| [:serve "player102"->"team203" @0 {end_year: 2015, start_year: 2006}] | +| [:serve "player102"->"team204" @0 {end_year: 2019, start_year: 2015}] | ++-----------------------------------------------------------------------+ +``` + ### 查询多个 Edge type 场景:查询起始点关联的多个边类型可以通过设置多个Edge Type实现,也可以通过设置`*`关联所有的边类型。