Skip to content

Commit

Permalink
Update 5.lookup.md (#1130)
Browse files Browse the repository at this point in the history
  • Loading branch information
randomJoe211 authored Nov 1, 2021
1 parent 03fb36f commit 4f74430
Showing 1 changed file with 30 additions and 32 deletions.
62 changes: 30 additions & 32 deletions docs-2.0/3.ngql-guide/7.general-query-statements/5.lookup.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ nebula> LOOKUP ON player \
+-------------+
| VertexID |
+-------------+
| "player144" |
| "player140" |
| "player144" |
+-------------+
nebula> LOOKUP ON player \
Expand All @@ -109,20 +109,20 @@ nebula> LOOKUP ON player \
+-------------+-------------------------+------------------------+
| VertexID | properties(VERTEX).name | properties(VERTEX).age |
+-------------+-------------------------+------------------------+
| "player149" | "Ben Simmons" | 22 |
| "player134" | "Blake Griffin" | 30 |
| "player149" | "Ben Simmons" | 22 |
+-------------+-------------------------+------------------------+
nebula> LOOKUP ON player \
WHERE player.name == "Kobe Bryant"\
YIELD properties(vertex).name AS name |\
GO FROM $-.VertexID OVER serve \
YIELD $-.name, properties(edge).start_year, properties(edge).end_year, properties($$).name;
+---------------+------------------+----------------+--------------+
| $-.name | serve.start_year | serve.end_year | $$.team.name |
+---------------+------------------+----------------+--------------+
| "Kobe Bryant" | 1996 | 2016 | "Lakers" |
+---------------+------------------+----------------+--------------+
+---------------+-----------------------------+---------------------------+---------------------+
| $-.name | properties(EDGE).start_year | properties(EDGE).end_year | properties($$).name |
+---------------+-----------------------------+---------------------------+---------------------+
| "Kobe Bryant" | 1996 | 2016 | "Lakers" |
+---------------+-----------------------------+---------------------------+---------------------+
```

## 检索边
Expand All @@ -144,10 +144,9 @@ nebula> LOOKUP ON follow \
+-------------+-------------+---------+
| SrcVID | DstVID | Ranking |
+-------------+-------------+---------+
| "player101" | "player102" | 0 |
| "player133" | "player114" | 0 |
| "player133" | "player144" | 0 |
+-------------+-------------+---------+
| "player150" | "player143" | 0 |
| "player150" | "player137" | 0 |
| "player148" | "player136" | 0 |
...
nebula> LOOKUP ON follow \
Expand All @@ -156,10 +155,9 @@ nebula> LOOKUP ON follow \
+-------------+-------------+---------+-------------------------+
| SrcVID | DstVID | Ranking | properties(EDGE).degree |
+-------------+-------------+---------+-------------------------+
| "player121" | "player116" | 0 | 90 |
| "player121" | "player128" | 0 | 90 |
| "player121" | "player129" | 0 | 90 |
+-------------+-------------+---------+-------------------------+
| "player150" | "player143" | 0 | 90 |
| "player150" | "player137" | 0 | 90 |
| "player148" | "player136" | 0 | 90 |
...
nebula> LOOKUP ON follow \
Expand Down Expand Up @@ -210,26 +208,26 @@ nebula> LOOKUP ON follow \
+-------------+
```
- 查找Edge type为`like`的所有边的信息。
- 查找Edge type为`follow`的所有边的信息。
```ngql
nebula> CREATE EDGE like(likeness int);
nebula> CREATE EDGE follow(degree int);
nebula> CREATE EDGE INDEX like_index on like();
nebula> CREATE EDGE INDEX follow_index on follow();
nebula> REBUILD EDGE INDEX like_index;
nebula> REBUILD EDGE INDEX follow_index;
+------------+
| New Job Id |
+------------+
| 88 |
+------------+
nebula> INSERT EDGE like(likeness) \
nebula> INSERT EDGE follow(degree) \
VALUES "player100"->"player101":(95);
# 列出所有的 like 边。类似于 MATCH (s)-[e:like]->(d) RETURN id(s), rank(e), id(d) /*, type(e) */。
# 列出所有的 follow 边。类似于 MATCH (s)-[e:follow]->(d) RETURN id(s), rank(e), id(d) /*, type(e) */。
nebula)> LOOKUP ON like;
nebula)> LOOKUP ON follow;
+-------------+-------------+---------+
| SrcVID | DstVID | Ranking |
+-------------+-------------+---------+
Expand All @@ -239,26 +237,26 @@ nebula> LOOKUP ON follow \
## 统计点或边
统计Tag为`player`的点和Edge type为`like`的边。
统计Tag为`player`的点和Edge type为`follow`的边。
```ngql
nebula> LOOKUP ON player |\
YIELD COUNT(*) AS Player_Number;
+---------------+
| Player_Number |
+---------------+
| 2 |
| 51 |
+---------------+
nebula> LOOKUP ON like | \
YIELD COUNT(*) AS Like_Number;
+-------------+
| Like_Number |
+-------------+
| 1 |
+-------------+
nebula> LOOKUP ON follow | \
YIELD COUNT(*) AS Follow_Number;
+---------------+
| Follow_Number |
+---------------+
| 81 |
+---------------+
```

!!! note

使用[`show-stats`命令](./6.show/14.show-stats.md)也可以统计点和边。
使用[`SHOW STATS`命令](./6.show/14.show-stats.md)也可以统计点和边。

0 comments on commit 4f74430

Please sign in to comment.