Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lookup format #1061

Merged
merged 2 commits into from
Oct 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ RETURN
DESCRIBE
DESC
VERTEX
VERTICES
EDGE
EDGES
UPDATE
Expand Down
25 changes: 14 additions & 11 deletions docs-2.0/3.ngql-guide/7.general-query-statements/5.lookup.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# LOOKUP

<!-- 3.0强制使用YIELD后需要修改本文档,参考 https://confluence.nebula-graph.io/pages/viewpage.action?pageId=10723963 -->

`LOOKUP`根据索引遍历数据。用户可以使用`LOOKUP`实现如下功能:

- 根据`WHERE`子句搜索特定数据。
Expand Down Expand Up @@ -35,19 +37,20 @@
```ngql
LOOKUP ON {<vertex_tag> | <edge_type>}
[WHERE <expression> [AND <expression> ...]]
[YIELD <return_list>];
[YIELD <return_list> [AS <alias>]];

<return_list>
<prop_name> [AS <col_alias>] [, <prop_name> [AS <prop_alias>] ...];
```

- `WHERE <expression>`:指定遍历的过滤条件,还可以结合布尔运算符AND和OR一起使用。详情请参见[WHERE](../8.clauses-and-options/where.md)。

- `YIELD <return_list>`:指定要返回的结果和格式。
- `YIELD`:定义需要返回的输出。

- `LOOKUP`Tag时,除了返回定义的属性,额外返回`VertexID`。如果没有`YIELD`子句,返回`VertexID`。
- `LOOKUP`Edge type时,除了返回定义的属性,额外返回`起始点ID`、`目的点ID`和`rank`。如果没有`YIELD`子句,返回`起始点ID`、`目的点ID`和`rank`。

- 如果只有`WHERE`子句,没有`YIELD`子句:
- `LOOKUP`Tag时,返回点ID。
- `LOOKUP`Edge type时,返回起始点ID、目的点ID和rank。
- `AS`:设置别名。

## WHERE语句限制

Expand Down Expand Up @@ -83,12 +86,12 @@ nebula> LOOKUP ON player \

nebula> LOOKUP ON player \
WHERE player.name == "Tony Parker" \
YIELD player.name, player.age;
+-------------+---------------+------------+
| VertexID | player.name | player.age |
+-------------+---------------+------------+
| "player101" | "Tony Parker" | 36 |
+-------------+---------------+------------+
YIELD player.name AS name, player.age AS age;
+-------------+---------------+-----+
| VertexID | name | age |
+-------------+---------------+-----+
| "player101" | "Tony Parker" | 36 |
+-------------+---------------+-----+

nebula> LOOKUP ON player \
WHERE player.age > 45;
Expand Down