Skip to content

Commit

Permalink
Add statements of fetch all edges by a starting vertex&minor changes (v…
Browse files Browse the repository at this point in the history
…esoft-inc#2380)

* add statements of fetch all edges by a starting vertex&minor changes

Co-Authored-By: Chris Chen <[email protected]>

* add example to retrieve all edges

Co-Authored-By: Chris Chen <[email protected]>

* fix line display

Co-Authored-By: Chris Chen <[email protected]>

---------

Co-authored-by: Chris Chen <[email protected]>
  • Loading branch information
abby-cyber and ChrisChen2023 authored Nov 29, 2023
1 parent 05d8161 commit a9441d5
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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:
<!-- no toc -->
- [FETCH PROP ON](#fetch_prop_on)
- [LOOKUP ON](#lookup_on_id)
- [LOOKUP ON](#lookup_on)
- [GO](#go)
- [MATCH](#match)
- [FIND PATH](#find_path)
Expand All @@ -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).
Expand All @@ -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).
Expand All @@ -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).
Expand Down Expand Up @@ -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).
Expand All @@ -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
```

Expand Down
20 changes: 20 additions & 0 deletions docs-2.0-en/3.ngql-guide/7.general-query-statements/3.go.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{{nebula.name}} 的核心查询语句可分为:
<!-- no toc -->
- [FETCH PROP ON](#fetch_prop_on)
- [LOOKUP ON](#lookup_on_id)
- [LOOKUP ON](#lookup_on)
- [GO](#go)
- [MATCH](#match)
- [FIND PATH](#find_path)
Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand Down
Loading

0 comments on commit a9441d5

Please sign in to comment.