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

update lookup #812

Merged
merged 2 commits into from
Oct 18, 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
29 changes: 16 additions & 13 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

<!-- This topic needs to be modified after compulsory use of YIELD in 3.0. Refer to https://confluence.nebula-graph.io/pages/viewpage.action?pageId=10723963 -->

The `LOOKUP` statement traverses data based on indexes. You can use `LOOKUP` for the following purposes:

- Search for the specific data based on conditions defined by the `WHERE` clause.
Expand Down Expand Up @@ -35,19 +37,20 @@ Before using the `LOOKUP` statement, make sure that at least one index is create
```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>`: filters data with specified conditions. Both `AND` and `OR` are supported between different expressions. For more information, see [WHERE](../8.clauses-and-options/where.md).

- `YIELD <return_list>`: specifies the results to be returned and the format of the results.
- `YIELD`: Define the output to be returned.

- When you `LOOKUP` a Tag, the defined properties and `VertexID` are returned. If there is no `YIELD` clause, `VertexID` is returned.
- When you `LOOKUP` an Edge type, the defined properties, `SrcVertexID`, `DstVertexID`, and `rank` are returned. If there is no `YIELD` clause, `SrcVertexID`, `DstVertexID`, and `rank` are returned.

- If there is a `WHERE` clause but no `YIELD` clause:
- The Vertex ID is returned when you `LOOKUP` a tag.
- The source vertex ID, destination vertex ID, and rank of the edge are returned when `LOOKUP` an edge type.
- `AS`: Set an alias.

## Limitations of using `WHERE` in `LOOKUP`

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 Expand Up @@ -208,7 +211,7 @@ For example, if there is a `player` tag with a `name` property and an `age` prop

nebula> LOOKUP ON player;
+-------------+
| _vid |
| VertexID |
+-------------+
| "player100" |
+-------------+
Expand Down Expand Up @@ -237,7 +240,7 @@ For example, if there is a `player` tag with a `name` property and an `age` prop

nebula)> LOOKUP ON like;
+-------------+----------+-------------+
| _src | _ranking | _dst |
| VertexID | DstVID | _dst |
+-------------+----------+-------------+
| "player100" | 0 | "player101" |
+-------------+----------+-------------+
Expand Down