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 #1050

Merged
merged 1 commit into from
Oct 12, 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

不支持跨Tag或Edge type创建复合索引。

复合属性索引被(`LOOKUP` 或者 `MATCH`)使用时,遵循"最左匹配原则",必须从复合属性索引的最左侧开始匹配。请参见下方示例。

```ngql
# 为Tag t的前三个属性创建复合属性索引。
nebula> CREATE TAG INDEX example_index ON t(p1, p2, p3);

# 注意:无法匹配到索引,因为不是从p1开始。
nebula> LOOKUP ON t WHERE p2 == 1 and p3 == 1;

# 可以匹配到索引。
nebula> LOOKUP ON t WHERE p1 == 1;
# 可以匹配到索引,因为p1和p2是连续的。
nebula> LOOKUP ON t WHERE p1 == 1 and p2 == 1;
# 可以匹配到索引,因为p1、p2、p3是连续的。
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 @@ Nebula Graph支持两种类型索引:原生索引和全文索引。

- 支持创建同一个Tag或Edge type的多个属性的索引(复合索引),但是不能跨Tag或Edge type。

- 复合索引可以实现部分匹配检索,遵循最左匹配原则。详情请参见[LOOKUP FAQ](../7.general-query-statements/5.lookup.md#faq)。

- [LOOKUP](../7.general-query-statements/5.lookup.md)不支持`CONTAINS`和`STARTS WITH`等字符串操作符。

### 原生索引操作

- [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 @@ LOOKUP ON {<vertex_tag> | <edge_type>}
- `$-`和`$^`。
- 在关系表达式中,不支持运算符两边都有字段名,例如`tagName.prop1 > tagName.prop2`。
- 不支持运算表达式和函数表达式中嵌套AliasProp表达式。
- 字符串类型索引不支持范围扫描。
- 不支持XOR和NOT运算符。
- 不支持除`STARTS WITH`之外的字符串操作。

## 检索点

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" |
+---------------+------------------+----------------+--------------+
```

## 检索边
Expand Down