From 3f6290911a1a2e1faa378c768cce2d8f450bb033 Mon Sep 17 00:00:00 2001 From: cooper-lzy <78672629+cooper-lzy@users.noreply.github.com> Date: Tue, 12 Oct 2021 17:21:12 +0800 Subject: [PATCH] lookup support use IN (#1050) --- .../1.create-native-index.md | 17 ------ .../14.native-index-statements/README.md | 4 -- .../7.general-query-statements/5.lookup.md | 54 +++++++++++++------ 3 files changed, 38 insertions(+), 37 deletions(-) diff --git a/docs-2.0/3.ngql-guide/14.native-index-statements/1.create-native-index.md b/docs-2.0/3.ngql-guide/14.native-index-statements/1.create-native-index.md index 9bb3a0e35c8..c6b398725a5 100644 --- a/docs-2.0/3.ngql-guide/14.native-index-statements/1.create-native-index.md +++ b/docs-2.0/3.ngql-guide/14.native-index-statements/1.create-native-index.md @@ -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; -``` diff --git a/docs-2.0/3.ngql-guide/14.native-index-statements/README.md b/docs-2.0/3.ngql-guide/14.native-index-statements/README.md index 2f8b6662c37..f6a45491e74 100644 --- a/docs-2.0/3.ngql-guide/14.native-index-statements/README.md +++ b/docs-2.0/3.ngql-guide/14.native-index-statements/README.md @@ -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) diff --git a/docs-2.0/3.ngql-guide/7.general-query-statements/5.lookup.md b/docs-2.0/3.ngql-guide/7.general-query-statements/5.lookup.md index 5c2dc5744e6..a57fd4127d4 100644 --- a/docs-2.0/3.ngql-guide/7.general-query-statements/5.lookup.md +++ b/docs-2.0/3.ngql-guide/7.general-query-statements/5.lookup.md @@ -56,8 +56,8 @@ LOOKUP ON { | } - `$-`和`$^`。 - 在关系表达式中,不支持运算符两边都有字段名,例如`tagName.prop1 > tagName.prop2`。 - 不支持运算表达式和函数表达式中嵌套AliasProp表达式。 -- 字符串类型索引不支持范围扫描。 - 不支持XOR和NOT运算符。 +- 不支持除`STARTS WITH`之外的字符串操作。 ## 检索点 @@ -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" | ++---------------+------------------+----------------+--------------+ ``` ## 检索边