From cfef82903704c6249f80f4e79f332d2e31ea1419 Mon Sep 17 00:00:00 2001 From: cooper-lzy <78672629+cooper-lzy@users.noreply.github.com> Date: Wed, 13 Oct 2021 09:27:12 +0800 Subject: [PATCH 1/2] lookup support use IN --- .../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 db4ddca95ba..97e5aa11a50 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 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; -``` 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 f2f6b1eb4a4..293d16ab75d 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 @@ 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) 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 1299379211c..9a30bc1e475 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 @@ 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. + ## Retrieve Vertices @@ -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 From 83bdd26fdc584a712f38a6d7c5c4668092cb2ca1 Mon Sep 17 00:00:00 2001 From: "max.zhu@vesoft.com" <86282370+izhuxiaoqing@users.noreply.github.com> Date: Thu, 14 Oct 2021 10:58:08 +0800 Subject: [PATCH 2/2] Update 5.lookup.md --- docs-2.0/3.ngql-guide/7.general-query-statements/5.lookup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 9a30bc1e475..5ecbc4e0949 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 @@ -57,7 +57,7 @@ The `WHERE` clause in a `LOOKUP` statement does not support the following operat - 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. - The `XOR` and `NOT` operations are not supported. - + ## Retrieve Vertices