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 support use IN #801

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 @@ -124,20 +124,3 @@ nebula> CREATE TAG INDEX player_index_1 on player(name(10), age);
!!! caution

Creating composite property indexes across multiple tags or edge types is not supported.

Nebula Graph follows the left matching principle to select indexes when composite property indexes are used in `LOOKUP` or `MATCH` statements. That is, columns in the `WHERE` conditions must be in the first N columns of the index. For example:

```ngql
# This example creates a composite property index for the first 3 properties of tag t.
nebula> CREATE TAG INDEX example_index ON t(p1, p2, p3);

# Note: The index match is not successful because it does not start from p1.
nebula> LOOKUP ON t WHERE p2 == 1 and p3 == 1;

# The index match is successful.
nebula> LOOKUP ON t WHERE p1 == 1;
# The index match is successful because p1 and p2 are consecutive.
nebula> LOOKUP ON t WHERE p1 == 1 and p2 == 1;
# The index match is successful because p1, p2, and p3 are consecutive.
nebula> LOOKUP ON t WHERE p1 == 1 and p2 == 1 and p3 == 1;
```
4 changes: 0 additions & 4 deletions docs-2.0/3.ngql-guide/14.native-index-statements/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ Native indexes allow querying data based on a given property. Features are as fo

- Native indexes support indexing multiple properties on a tag or an edge type (composite indexes), but do not support indexing across multiple tags or edge types.

- You can do partial match searches by using composite indexes. The declared fields in the composite index are used from left to right. For more information, see [LOOKUP FAQ](../7.general-query-statements/5.lookup.md#FAQ).

- String operators like `CONTAINS` and `STARTS WITH` are not allowed in [LOOKUP](../7.general-query-statements/5.lookup.md) for native index searching. Use full-text indexes to do fuzzy searches.

### Operations on native indexes

- [CREATE INDEX](1.create-native-index.md)
Expand Down
54 changes: 38 additions & 16 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 @@ -56,8 +56,8 @@ The `WHERE` clause in a `LOOKUP` statement does not support the following operat
- `$-` and `$^`.
- In relational expressions, operators are not supported to have field names on both sides, such as `tagName.prop1> tagName.prop2`.
- Nested AliasProp expressions in operation expressions and function expressions are not supported.
- Range scan is not supported in the string-type index.
- The `XOR` and `NOT` operations are not supported.
<!-- - String operations other than `STARTS WITH` are not supported.-->

## Retrieve Vertices

Expand All @@ -75,31 +75,53 @@ nebula> REBUILD TAG INDEX index_player;

nebula> LOOKUP ON player \
WHERE player.name == "Tony Parker";
============
| VertexID |
============
| 101 |
------------
+-------------+
| VertexID |
+-------------+
| "player101" |
+-------------+

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

nebula> LOOKUP ON player \
WHERE player.age > 45;
+-------------+
| VertexID |
+-------------+
| "player144" |
+-------------+
| "player140" |
+-------------+

nebula> LOOKUP ON player \
WHERE player.name STARTS WITH "B" \
AND player.age IN [22,30] \
YIELD player.name, player.age;
+-------------+-----------------+------------+
| VertexID | player.name | player.age |
+-------------+-----------------+------------+
| "player149" | "Ben Simmons" | 22 |
+-------------+-----------------+------------+
| "player134" | "Blake Griffin" | 30 |
+-------------+-----------------+------------+

nebula> LOOKUP ON player \
WHERE player.name == "Kobe Bryant" \
YIELD player.name AS name |\
GO FROM $-.VertexID OVER serve \
YIELD $-.name, serve.start_year, serve.end_year, $$.team.name;
==================================================================
| $-.name | serve.start_year | serve.end_year | $$.team.name |
==================================================================
| Kobe Bryant | 1996 | 2016 | Lakers |
------------------------------------------------------------------
+---------------+------------------+----------------+--------------+
| $-.name | serve.start_year | serve.end_year | $$.team.name |
+---------------+------------------+----------------+--------------+
| "Kobe Bryant" | 1996 | 2016 | "Lakers" |
+---------------+------------------+----------------+--------------+
```

## Retrieve Edges
Expand Down