From 9afe560f3acca9a3c299021805e5a7db6673b2e5 Mon Sep 17 00:00:00 2001 From: cooper-lzy <78672629+cooper-lzy@users.noreply.github.com> Date: Mon, 6 Dec 2021 15:16:59 +0800 Subject: [PATCH 1/3] add yield clause for all ngql --- docs-2.0/2.quick-start/4.nebula-graph-crud.md | 78 ++++++----- .../10.tag-statements/6.delete-tag.md | 19 +-- .../improve-query-by-tag-index.md | 8 +- .../12.vertex-statements/1.insert-vertex.md | 48 +++---- .../12.vertex-statements/2.update-vertex.md | 12 +- .../12.vertex-statements/3.upsert-vertex.md | 37 ++--- .../13.edge-statements/1.insert-edge.md | 8 +- .../13.edge-statements/3.upsert-edge.md | 4 + .../1.search-with-text-based-index.md | 42 +++--- .../16.subgraph-and-path/1.get-subgraph.md | 4 +- .../16.subgraph-and-path/2.find-path.md | 16 +-- docs-2.0/3.ngql-guide/3.data-types/5.null.md | 12 +- docs-2.0/3.ngql-guide/5.operators/4.pipe.md | 4 +- docs-2.0/3.ngql-guide/5.operators/6.set.md | 26 ++-- .../6.functions-and-expressions/11.reduce.md | 2 +- .../6.functions-and-expressions/4.schema.md | 13 +- .../7.general-query-statements/3.go.md | 29 ++-- .../7.general-query-statements/4.fetch.md | 130 +++++++++--------- .../7.general-query-statements/5.lookup.md | 110 +++++++-------- .../8.clauses-and-options/limit.md | 23 ++-- .../8.clauses-and-options/order-by.md | 16 +-- .../8.clauses-and-options/where.md | 34 ++--- .../8.clauses-and-options/yield.md | 22 +-- .../use-console/st-ug-visualize-subgraph.md | 2 +- .../reuse/source_connect-to-nebula-graph.md | 8 +- 25 files changed, 363 insertions(+), 344 deletions(-) diff --git a/docs-2.0/2.quick-start/4.nebula-graph-crud.md b/docs-2.0/2.quick-start/4.nebula-graph-crud.md index c51e78c9cb7..23b06628400 100644 --- a/docs-2.0/2.quick-start/4.nebula-graph-crud.md +++ b/docs-2.0/2.quick-start/4.nebula-graph-crud.md @@ -248,7 +248,7 @@ nebula> CREATE EDGE serve(start_year int, end_year int); GO [[ TO] STEPS ] FROM OVER [{REVERSELY | BIDIRECT}] [ WHERE  ] - [YIELD [DISTINCT] ] + YIELD [DISTINCT] [{SAMPLE | LIMIT }] [| GROUP BY {col_name | expr | position} YIELD ] [| ORDER BY [{ASC | DESC}]] @@ -262,14 +262,14 @@ nebula> CREATE EDGE serve(start_year int, end_year int); ```ngql FETCH PROP ON {[, tag_name ...] | *} [, vid ...] - [YIELD [AS ]]; + YIELD [AS ]; ``` - 查询边属性 ```ngql FETCH PROP ON -> [@] [, -> ...] - [YIELD ]; + YIELD ; ``` - `LOOKUP` @@ -277,7 +277,7 @@ nebula> CREATE EDGE serve(start_year int, end_year int); ```ngql LOOKUP ON { | } [WHERE [AND ...]] - [YIELD [AS ]]; + YIELD [AS ]; ``` - `MATCH` @@ -291,12 +291,13 @@ nebula> CREATE EDGE serve(start_year int, end_year int); - 从 VID 为`player101`的球员开始,沿着边`follow`找到连接的球员。 ```ngql - nebula> GO FROM "player101" OVER follow; + nebula> GO FROM "player101" OVER follow YIELD id($$); +-------------+ - | follow._dst | + | id($$) | +-------------+ | "player100" | | "player102" | + | "player125" | +-------------+ ``` @@ -305,11 +306,12 @@ nebula> CREATE EDGE serve(start_year int, end_year int); ```ngql nebula> GO FROM "player101" OVER follow WHERE properties($$).age >= 35 \ YIELD properties($$).name AS Teammate, properties($$).age AS Age; - +--------------+-----+ - | Teammate | Age | - +--------------+-----+ - | "Tim Duncan" | 42 | - +--------------+-----+ + +-----------------+-----+ + | Teammate | Age | + +-----------------+-----+ + | "Tim Duncan" | 42 | + | "Manu Ginobili" | 41 | + +-----------------+-----+ ``` |子句/符号|说明| @@ -329,7 +331,10 @@ nebula> CREATE EDGE serve(start_year int, end_year int); +-----------------+---------------------+ | Team | Player | +-----------------+---------------------+ + | "Spurs" | "Tim Duncan" | | "Trail Blazers" | "LaMarcus Aldridge" | + | "Spurs" | "LaMarcus Aldridge" | + | "Spurs" | "Manu Ginobili" | +-----------------+---------------------+ ``` @@ -352,7 +357,10 @@ nebula> CREATE EDGE serve(start_year int, end_year int); +-----------------+---------------------+ | Team | Player | +-----------------+---------------------+ + | "Spurs" | "Tim Duncan" | | "Trail Blazers" | "LaMarcus Aldridge" | + | "Spurs" | "LaMarcus Aldridge" | + | "Spurs" | "Manu Ginobili" | +-----------------+---------------------+ ``` @@ -361,12 +369,12 @@ nebula> CREATE EDGE serve(start_year int, end_year int); 查询 VID 为`player100`的球员的属性。 ```ngql -nebula> FETCH PROP ON player "player100"; -+----------------------------------------------------+ -| vertices_ | -+----------------------------------------------------+ -| ("player100" :player{age: 42, name: "Tim Duncan"}) | -+----------------------------------------------------+ +nebula> FETCH PROP ON player "player100" YIELD properties(vertex); ++-------------------------------+ +| properties(VERTEX) | ++-------------------------------+ +| {age: 42, name: "Tim Duncan"} | ++-------------------------------+ ``` !!! Note @@ -413,12 +421,12 @@ nebula> FETCH PROP ON player "player100"; ```ngql nebula> UPDATE VERTEX "player100" SET player.name = "Tim"; - nebula> FETCH PROP ON player "player100"; - +---------------------------------------------+ - | vertices_ | - +---------------------------------------------+ - | ("player100" :player{age: 42, name: "Tim"}) | - +---------------------------------------------+ + nebula> FETCH PROP ON player "player100" YIELD properties(vertex); + +------------------------+ + | properties(VERTEX) | + +------------------------+ + | {age: 42, name: "Tim"} | + +------------------------+ ``` - 用`UPDATE`修改某条边的`degree`属性,然后用`FETCH`检查结果。 @@ -426,12 +434,12 @@ nebula> FETCH PROP ON player "player100"; ```ngql nebula> UPDATE EDGE "player101" -> "player100" OF follow SET degree = 96; - nebula> FETCH PROP ON follow "player101" -> "player100"; - +----------------------------------------------------+ - | edges_ | - +----------------------------------------------------+ - | [:follow "player101"->"player100" @0 {degree: 96}] | - +----------------------------------------------------+ + nebula> FETCH PROP ON follow "player101" -> "player100" YIELD properties(edge); + +------------------+ + | properties(EDGE) | + +------------------+ + | {degree: 96} | + +------------------+ ``` - 用`INSERT`插入一个 VID 为`player111`的点,然后用`UPSERT`更新它。 @@ -517,7 +525,7 @@ nebula> FETCH PROP ON player "player100"; ```nGQL // 为 name 属性创建索引 player_index_1。 -nebula> CREATE TAG INDEX player_index_1 ON player(name(20)); +nebula> CREATE TAG INDEX IF NOT EXISTS player_index_1 ON player(name(20)); // 重建索引确保能对已存在数据生效。 nebula> REBUILD TAG INDEX player_index_1 @@ -530,11 +538,11 @@ nebula> REBUILD TAG INDEX player_index_1 // 使用 LOOKUP 语句检索点的属性。 nebula> LOOKUP ON player WHERE player.name == "Tony Parker" \ YIELD properties(vertex).name AS name, properties(vertex).age AS age; -+-------------+---------------+-----+ -| VertexID | name | age | -+-------------+---------------+-----+ -| "player101" | "Tony Parker" | 36 | -+-------------+---------------+-----+ ++---------------+-----+ +| name | age | ++---------------+-----+ +| "Tony Parker" | 36 | ++---------------+-----+ // 使用 MATCH 语句检索点的属性。 nebula> MATCH (v:player{name:"Tony Parker"}) RETURN v; diff --git a/docs-2.0/3.ngql-guide/10.tag-statements/6.delete-tag.md b/docs-2.0/3.ngql-guide/10.tag-statements/6.delete-tag.md index 546ab020a2d..e4eaef7a963 100644 --- a/docs-2.0/3.ngql-guide/10.tag-statements/6.delete-tag.md +++ b/docs-2.0/3.ngql-guide/10.tag-statements/6.delete-tag.md @@ -28,26 +28,27 @@ DELETE TAG FROM ; nebula> CREATE TAG IF NOT EXISTS test1(p1 string, p2 int); nebula> CREATE TAG IF NOT EXISTS test2(p3 string, p4 int); nebula> INSERT VERTEX test1(p1, p2),test2(p3, p4) VALUES "test":("123", 1, "456", 2); -nebula> FETCH PROP ON * "test"; +nebula> FETCH PROP ON * "test" YIELD vertex AS v; +------------------------------------------------------------+ -| vertices_ | +| v | +------------------------------------------------------------+ -| ("test" :test2{p3: "456", p4: 2} :test1{p1: "123", p2: 1}) | +| ("test" :test1{p1: "123", p2: 1} :test2{p3: "456", p4: 2}) | +------------------------------------------------------------+ nebula> DELETE TAG test1 FROM "test"; -nebula> FETCH PROP ON * "test"; +nebula> FETCH PROP ON * "test" YIELD vertex AS v; +-----------------------------------+ -| vertices_ | +| v | +-----------------------------------+ | ("test" :test2{p3: "456", p4: 2}) | +-----------------------------------+ nebula> DELETE TAG * FROM "test"; -nebula> FETCH PROP ON * "test"; -+-----------+ -| vertices_ | -+-----------+ +nebula> FETCH PROP ON * "test" YIELD vertex AS v; ++---+ +| v | ++---+ ++---+ ``` !!! Compatibility diff --git a/docs-2.0/3.ngql-guide/10.tag-statements/improve-query-by-tag-index.md b/docs-2.0/3.ngql-guide/10.tag-statements/improve-query-by-tag-index.md index 9ad2c1c1fdd..2db58844608 100644 --- a/docs-2.0/3.ngql-guide/10.tag-statements/improve-query-by-tag-index.md +++ b/docs-2.0/3.ngql-guide/10.tag-statements/improve-query-by-tag-index.md @@ -29,9 +29,9 @@ nebula> MATCH (v:shareholder) RETURN v; | ("player100" :player{age: 42, name: "Tim Duncan"} :shareholder{}) | | ("player101" :player{age: 36, name: "Tony Parker"} :shareholder{}) | +---------------------------------------------------------------------+ -nebula> LOOKUP ON shareholder; +nebula> LOOKUP ON shareholder YIELD id(vertex); +-------------+ -| VertexID | +| id(VERTEX) | +-------------+ | "player100" | | "player101" | @@ -39,9 +39,9 @@ nebula> LOOKUP ON shareholder; //如果 player100 不再是股东 nebula> DELETE TAG shareholder FROM "player100"; -nebula> LOOKUP ON shareholder; +nebula> LOOKUP ON shareholder YIELD id(vertex); +-------------+ -| VertexID | +| id(VERTEX) | +-------------+ | "player101" | +-------------+ diff --git a/docs-2.0/3.ngql-guide/12.vertex-statements/1.insert-vertex.md b/docs-2.0/3.ngql-guide/12.vertex-statements/1.insert-vertex.md index b6ad732c324..3e483ef4184 100644 --- a/docs-2.0/3.ngql-guide/12.vertex-statements/1.insert-vertex.md +++ b/docs-2.0/3.ngql-guide/12.vertex-statements/1.insert-vertex.md @@ -78,12 +78,12 @@ nebula> INSERT VERTEX t3 (p1), t4(p2) VALUES "21": (321, "hello"); nebula> INSERT VERTEX t2 (name, age) VALUES "11":("n2", 13); nebula> INSERT VERTEX t2 (name, age) VALUES "11":("n3", 14); nebula> INSERT VERTEX t2 (name, age) VALUES "11":("n4", 15); -nebula> FETCH PROP ON t2 "11"; -+---------------------------------+ -| vertices_ | -+---------------------------------+ -| ("11" :t2{age: 15, name: "n4"}) | -+---------------------------------+ +nebula> FETCH PROP ON t2 "11" YIELD properties(vertex); ++-----------------------+ +| properties(VERTEX) | ++-----------------------+ +| {age: 15, name: "n4"} | ++-----------------------+ ``` ```ngql @@ -96,21 +96,21 @@ nebula> INSERT VERTEX t5(p1, p2, p3) VALUES "002":(NULL, 4, 5); # 属性 p3 为默认值 NULL。 nebula> INSERT VERTEX t5(p1, p2) VALUES "003":("cd", 5); -nebula> FETCH PROP ON t5 "003"; -+--------------------------------------------+ -| vertices_ | -+--------------------------------------------+ -| ("003" :t5{p1: "cd", p2: 5, p3: __NULL__}) | -+--------------------------------------------+ +nebula> FETCH PROP ON t5 "003" YIELD properties(vertex); ++---------------------------------+ +| properties(VERTEX) | ++---------------------------------+ +| {p1: "cd", p2: 5, p3: __NULL__} | ++---------------------------------+ # 属性 p1 最大长度为 5,因此会被截断。 nebula> INSERT VERTEX t5(p1, p2) VALUES "004":("shalalalala", 4); -nebula> FETCH PROP on t5 "004"; -+-----------------------------------------------+ -| vertices_ | -+-----------------------------------------------+ -| ("004" :t5{p1: "shala", p2: 4, p3: __NULL__}) | -+-----------------------------------------------+ +nebula> FETCH PROP on t5 "004" YIELD properties(vertex); ++------------------------------------+ +| properties(VERTEX) | ++------------------------------------+ +| {p1: "shala", p2: 4, p3: __NULL__} | ++------------------------------------+ ``` 使用`IF NOT EXISTS`插入已存在的点时,不会进行修改。 @@ -120,10 +120,10 @@ nebula> FETCH PROP on t5 "004"; nebula> INSERT VERTEX t2 (name, age) VALUES "1":("n2", 13); # 使用 IF NOT EXISTS 修改点 1,因为点 1 已存在,不会进行修改。 nebula> INSERT VERTEX IF NOT EXISTS t2 (name, age) VALUES "1":("n3", 14); -nebula> FETCH PROP ON t2 "1"; -+--------------------------------+ -| vertices_ | -+--------------------------------+ -| ("1" :t2{age: 13, name: "n2"}) | -+--------------------------------+ +nebula> FETCH PROP ON t2 "1" YIELD properties(vertex); ++-----------------------+ +| properties(VERTEX) | ++-----------------------+ +| {age: 13, name: "n2"} | ++-----------------------+ ``` diff --git a/docs-2.0/3.ngql-guide/12.vertex-statements/2.update-vertex.md b/docs-2.0/3.ngql-guide/12.vertex-statements/2.update-vertex.md index a5ed3c14471..2a38b292df5 100644 --- a/docs-2.0/3.ngql-guide/12.vertex-statements/2.update-vertex.md +++ b/docs-2.0/3.ngql-guide/12.vertex-statements/2.update-vertex.md @@ -29,12 +29,12 @@ SET ```ngql // 查看点”player101“的属性。 -nebula> FETCH PROP ON player "player101"; -+-----------------------------------------------------+ -| vertices_ | -+-----------------------------------------------------+ -| ("player101" :player{age: 36, name: "Tony Parker"}) | -+-----------------------------------------------------+ +nebula> FETCH PROP ON player "player101" YIELD properties(vertex); ++--------------------------------+ +| properties(VERTEX) | ++--------------------------------+ +| {age: 36, name: "Tony Parker"} | ++--------------------------------+ // 修改属性 age 的值,并返回 name 和新的 age。 nebula> UPDATE VERTEX ON player "player101" \ diff --git a/docs-2.0/3.ngql-guide/12.vertex-statements/3.upsert-vertex.md b/docs-2.0/3.ngql-guide/12.vertex-statements/3.upsert-vertex.md index 05951c2e86a..4873fdbaf57 100644 --- a/docs-2.0/3.ngql-guide/12.vertex-statements/3.upsert-vertex.md +++ b/docs-2.0/3.ngql-guide/12.vertex-statements/3.upsert-vertex.md @@ -56,10 +56,11 @@ SET ```ngql // 查看三个点是否存在,结果 “Empty set” 表示顶点不存在。 -nebula> FETCH PROP ON * "player666", "player667", "player668"; -+-----------+ -| vertices_ | -+-----------+ +nebula> FETCH PROP ON * "player666", "player667", "player668" YIELD properties(vertex); ++--------------------+ +| properties(VERTEX) | ++--------------------+ ++--------------------+ Empty set nebula> UPSERT VERTEX ON player "player666" \ @@ -123,12 +124,12 @@ nebula> UPSERT VERTEX ON player_with_default "player101" \ 如果点存在,且满足`WHEN`子句的条件,就会修改点的属性值。 ```ngql -nebula> FETCH PROP ON player "player101"; -+-----------------------------------------------------+ -| vertices_ | -+-----------------------------------------------------+ -| ("player101" :player{age: 42, name: "Tony Parker"}) | -+-----------------------------------------------------+ +nebula> FETCH PROP ON player "player101" YIELD properties(vertex); ++--------------------------------+ +| properties(VERTEX) | ++--------------------------------+ +| {age: 36, name: "Tony Parker"} | ++--------------------------------+ nebula> UPSERT VERTEX ON player "player101" \ SET age = age + 2 \ @@ -137,19 +138,19 @@ nebula> UPSERT VERTEX ON player "player101" \ +---------------+-----+ | Name | Age | +---------------+-----+ -| "Tony Parker" | 44 | +| "Tony Parker" | 38 | +---------------+-----+ ``` 如果点存在,但是不满足`WHEN`子句的条件,修改不会生效。 ```ngql -nebula> FETCH PROP ON player "player101"; -+-----------------------------------------------------+ -| vertices_ | -+-----------------------------------------------------+ -| ("player101" :player{age: 44, name: "Tony Parker"}) | -+-----------------------------------------------------+ +nebula> FETCH PROP ON player "player101" YIELD properties(vertex); ++--------------------------------+ +| properties(VERTEX) | ++--------------------------------+ +| {age: 38, name: "Tony Parker"} | ++--------------------------------+ nebula> UPSERT VERTEX ON player "player101" \ SET age = age + 2 \ @@ -158,6 +159,6 @@ nebula> UPSERT VERTEX ON player "player101" \ +---------------+-----+ | Name | Age | +---------------+-----+ -| "Tony Parker" | 44 | +| "Tony Parker" | 38 | +---------------+-----+ ``` \ No newline at end of file diff --git a/docs-2.0/3.ngql-guide/13.edge-statements/1.insert-edge.md b/docs-2.0/3.ngql-guide/13.edge-statements/1.insert-edge.md index ea99dbff116..6d1cb86a1c2 100644 --- a/docs-2.0/3.ngql-guide/13.edge-statements/1.insert-edge.md +++ b/docs-2.0/3.ngql-guide/13.edge-statements/1.insert-edge.md @@ -71,9 +71,9 @@ nebula> INSERT EDGE e2 (name, age) VALUES "11"->"13":("n1", "a13"); nebula> INSERT EDGE e2 (name, age) VALUES "11"->"13":("n1", 12); nebula> INSERT EDGE e2 (name, age) VALUES "11"->"13":("n1", 13); nebula> INSERT EDGE e2 (name, age) VALUES "11"->"13":("n1", 14); -nebula> FETCH PROP ON e2 "11"->"13"; +nebula> FETCH PROP ON e2 "11"->"13" YIELD edge AS e; +-------------------------------------------+ -| edges_ | +| e | +-------------------------------------------+ | [:e2 "11"->"13" @0 {age: 14, name: "n1"}] | +-------------------------------------------+ @@ -86,9 +86,9 @@ nebula> FETCH PROP ON e2 "11"->"13"; nebula> INSERT EDGE e2 (name, age) VALUES "14"->"15"@1:("n1", 12); # 使用 IF NOT EXISTS 修改边,因为边已存在,不会进行修改。 nebula> INSERT EDGE IF NOT EXISTS e2 (name, age) VALUES "14"->"15"@1:("n2", 13); -nebula> FETCH PROP ON e2 "14"->"15"@1; +nebula> FETCH PROP ON e2 "14"->"15"@1 YIELD edge AS e; +-------------------------------------------+ -| edges_ | +| e | +-------------------------------------------+ | [:e2 "14"->"15" @1 {age: 12, name: "n1"}] | +-------------------------------------------+ diff --git a/docs-2.0/3.ngql-guide/13.edge-statements/3.upsert-edge.md b/docs-2.0/3.ngql-guide/13.edge-statements/3.upsert-edge.md index e3ae15a3831..0a4e85d7bdd 100644 --- a/docs-2.0/3.ngql-guide/13.edge-statements/3.upsert-edge.md +++ b/docs-2.0/3.ngql-guide/13.edge-statements/3.upsert-edge.md @@ -58,6 +58,10 @@ SET nebula> GO FROM "player666", "player667", "player668" \ OVER serve \ YIELD properties(edge).start_year, properties(edge).end_year; ++-----------------------------+---------------------------+ +| properties(EDGE).start_year | properties(EDGE).end_year | ++-----------------------------+---------------------------+ ++-----------------------------+---------------------------+ Empty set nebula> UPSERT EDGE on serve \ diff --git a/docs-2.0/3.ngql-guide/15.full-text-index-statements/1.search-with-text-based-index.md b/docs-2.0/3.ngql-guide/15.full-text-index-statements/1.search-with-text-based-index.md index 0ffb449f8b2..9f68ce88cc2 100644 --- a/docs-2.0/3.ngql-guide/15.full-text-index-statements/1.search-with-text-based-index.md +++ b/docs-2.0/3.ngql-guide/15.full-text-index-statements/1.search-with-text-based-index.md @@ -123,9 +123,9 @@ nebula> INSERT VERTEX player(name, age) VALUES \ "Blake Griffin": ("Blake Griffin", 30); //测试查询 -nebula> LOOKUP ON player WHERE PREFIX(player.name, "B"); +nebula> LOOKUP ON player WHERE PREFIX(player.name, "B") YIELD id(vertex); +-----------------+ -| _vid | +| id(VERTEX) | +-----------------+ | "Boris Diaw" | | "Ben Simmons" | @@ -133,13 +133,13 @@ nebula> LOOKUP ON player WHERE PREFIX(player.name, "B"); +-----------------+ nebula> LOOKUP ON player WHERE WILDCARD(player.name, "*ri*") YIELD player.name, player.age; -+-----------------+-----------------+-----+ -| _vid | name | age | -+-----------------+-----------------+-----+ -| "Chris Paul" | "Chris Paul" | 33 | -| "Boris Diaw" | "Boris Diaw" | 36 | -| "Blake Griffin" | "Blake Griffin" | 30 | -+-----------------+-----------------+-----+ ++-----------------+-----+ +| name | age | ++-----------------+-----+ +| "Chris Paul" | 33 | +| "Boris Diaw" | 36 | +| "Blake Griffin" | 30 | ++-----------------+-----+ nebula> LOOKUP ON player WHERE WILDCARD(player.name, "*ri*") | YIELD count(*); +----------+ @@ -149,15 +149,15 @@ nebula> LOOKUP ON player WHERE WILDCARD(player.name, "*ri*") | YIELD count(*); +----------+ nebula> LOOKUP ON player WHERE REGEXP(player.name, "R.*") YIELD player.name, player.age; -+---------------------+---------------------+-----+ -| _vid | name | age | -+---------------------+---------------------+-----+ -| "Russell Westbrook" | "Russell Westbrook" | 30 | -+---------------------+---------------------+-----+ ++---------------------+-----+ +| name | age | ++---------------------+-----+ +| "Russell Westbrook" | 30 | ++---------------------+-----+ -nebula> LOOKUP ON player WHERE REGEXP(player.name, ".*"); +nebula> LOOKUP ON player WHERE REGEXP(player.name, ".*") YIELD id(vertex); +---------------------+ -| _vid | +| id(VERTEX) | +---------------------+ | "Danny Green" | | "David West" | @@ -166,11 +166,11 @@ nebula> LOOKUP ON player WHERE REGEXP(player.name, ".*"); ... nebula> LOOKUP ON player WHERE FUZZY(player.name, "Tim Dunncan", AUTO, OR) YIELD player.name; -+--------------+--------------+ -| _vid | name | -+--------------+--------------+ -| "Tim Duncan" | "Tim Duncan" | -+--------------+--------------+ ++--------------+ +| name | ++--------------+ +| "Tim Duncan" | ++--------------+ //删除全文索引。 nebula> DROP FULLTEXT INDEX nebula_index_1; diff --git a/docs-2.0/3.ngql-guide/16.subgraph-and-path/1.get-subgraph.md b/docs-2.0/3.ngql-guide/16.subgraph-and-path/1.get-subgraph.md index f55c0832814..00f98d1513a 100644 --- a/docs-2.0/3.ngql-guide/16.subgraph-and-path/1.get-subgraph.md +++ b/docs-2.0/3.ngql-guide/16.subgraph-and-path/1.get-subgraph.md @@ -110,9 +110,9 @@ nebula> INSERT EDGE serve(start_year, end_year) VALUES "player101" -> "team204": 如果只是查询满足条件的路径或点,建议使用 [MATCH](../7.general-query-statements/2.match.md) 或 [GO](../7.general-query-statements/3.go.md) 语句。例如: ```ngql -nebula> match p= (v:player) -- (v2) where id(v)=="A" return p; +nebula> MATCH p= (v:player) -- (v2) WHERE id(v)=="A" RETURN p; -nebula> go 1 steps from "A" over follow; +nebula> GO 1 STEPS FROM "A" OVER follow YIELD id(vertex); ``` ### 为什么返回结果中会出现低于`step_count`跳数的关系? diff --git a/docs-2.0/3.ngql-guide/16.subgraph-and-path/2.find-path.md b/docs-2.0/3.ngql-guide/16.subgraph-and-path/2.find-path.md index 2ad7f7bd0e2..b45fc5f431e 100644 --- a/docs-2.0/3.ngql-guide/16.subgraph-and-path/2.find-path.md +++ b/docs-2.0/3.ngql-guide/16.subgraph-and-path/2.find-path.md @@ -51,27 +51,27 @@ OVER [REVERSELY | BIDIRECT] [] [UPTO STEPS] [ 返回的路径格式类似于`()-[:@]->( FIND SHORTEST PATH FROM "player102" TO "team204" OVER *; +nebula> FIND SHORTEST PATH FROM "player102" TO "team204" OVER * YIELD path AS p; +--------------------------------------------+ -| path | +| p | +--------------------------------------------+ | <("player102")-[:serve@0 {}]->("team204")> | +--------------------------------------------+ ``` ```ngql -nebula> FIND SHORTEST PATH WITH PROP FROM "team204" TO "player100" OVER * REVERSELY; +nebula> FIND SHORTEST PATH WITH PROP FROM "team204" TO "player100" OVER * REVERSELY YIELD path AS p; +--------------------------------------------------------------------------------------------------------------------------------------+ -| path | +| p | +--------------------------------------------------------------------------------------------------------------------------------------+ | <("team204" :team{name: "Spurs"})<-[:serve@0 {end_year: 2016, start_year: 1997}]-("player100" :player{age: 42, name: "Tim Duncan"})> | +--------------------------------------------------------------------------------------------------------------------------------------+ ``` ```ngql -nebula> FIND ALL PATH FROM "player100" TO "team204" OVER * WHERE follow.degree is EMPTY or follow.degree >=0; +nebula> FIND ALL PATH FROM "player100" TO "team204" OVER * WHERE follow.degree is EMPTY or follow.degree >=0 YIELD path AS p; +------------------------------------------------------------------------------+ -| path | +| p | +------------------------------------------------------------------------------+ | <("player100")-[:serve@0 {}]->("team204")> | | <("player100")-[:follow@0 {}]->("player125")-[:serve@0 {}]->("team204")> | @@ -81,9 +81,9 @@ nebula> FIND ALL PATH FROM "player100" TO "team204" OVER * WHERE follow.degree i ``` ```ngql -nebula> FIND NOLOOP PATH FROM "player100" TO "team204" OVER *; +nebula> FIND NOLOOP PATH FROM "player100" TO "team204" OVER * YIELD path AS p; +--------------------------------------------------------------------------------------------------------+ -| path | +| p | +--------------------------------------------------------------------------------------------------------+ | <("player100")-[:serve@0 {}]->("team204")> | | <("player100")-[:follow@0 {}]->("player125")-[:serve@0 {}]->("team204")> | diff --git a/docs-2.0/3.ngql-guide/3.data-types/5.null.md b/docs-2.0/3.ngql-guide/3.data-types/5.null.md index bd9fd384ed8..84419514686 100644 --- a/docs-2.0/3.ngql-guide/3.data-types/5.null.md +++ b/docs-2.0/3.ngql-guide/3.data-types/5.null.md @@ -77,10 +77,10 @@ nebula> INSERT VERTEX player(name) VALUES "Kobe":("Kobe"); 查询点`Kobe`,属性`age`为默认值`18`。 ```ngql -nebula> FETCH PROP ON player "Kobe"; -+-----------------------------------------+ -| vertices_ | -+-----------------------------------------+ -| ("Kobe" :player{age: 18, name: "Kobe"}) | -+-----------------------------------------+ +nebula> FETCH PROP ON player "Kobe" YIELD properties(vertex); ++--------------------------+ +| properties(VERTEX) | ++--------------------------+ +| {age: 18, name: "Kobe"} | ++--------------------------+ ``` diff --git a/docs-2.0/3.ngql-guide/5.operators/4.pipe.md b/docs-2.0/3.ngql-guide/5.operators/4.pipe.md index 5de8e6d115c..a21ebb17e36 100644 --- a/docs-2.0/3.ngql-guide/5.operators/4.pipe.md +++ b/docs-2.0/3.ngql-guide/5.operators/4.pipe.md @@ -19,10 +19,10 @@ nGQL 和 SQL 之间的一个主要区别是子查询的组成方式。 ```ngql nebula> GO FROM "player100" OVER follow \ YIELD dst(edge) AS dstid, properties($$).name AS Name | \ - GO FROM $-.dstid OVER follow; + GO FROM $-.dstid OVER follow YIELD dst(edge); +-------------+ -| follow._dst | +| dst(EDGE) | +-------------+ | "player100" | | "player102" | diff --git a/docs-2.0/3.ngql-guide/5.operators/6.set.md b/docs-2.0/3.ngql-guide/5.operators/6.set.md index c34c741bcfa..b3c0b2c150b 100644 --- a/docs-2.0/3.ngql-guide/5.operators/6.set.md +++ b/docs-2.0/3.ngql-guide/5.operators/6.set.md @@ -24,11 +24,11 @@ ```ngql # 返回两个查询结果的并集,不包含重复的元素。 -nebula> GO FROM "player102" OVER follow \ +nebula> GO FROM "player102" OVER follow YIELD dst(edge) \ UNION \ - GO FROM "player100" OVER follow; + GO FROM "player100" OVER follow YIELD dst(edge); +-------------+ -| follow._dst | +| dst(EDGE) | +-------------+ | "player100" | | "player101" | @@ -36,14 +36,15 @@ nebula> GO FROM "player102" OVER follow \ +-------------+ # 返回两个查询结果的并集,包含重复的元素。 -nebula> GO FROM "player102" OVER follow \ +nebula> GO FROM "player102" OVER follow YIELD dst(edge) \ UNION ALL \ - GO FROM "player100" OVER follow; + GO FROM "player100" OVER follow YIELD dst(edge); +-------------+ -| follow._dst | +| dst(EDGE) | +-------------+ | "player100" | | "player101" | +| "player101" | | "player125" | +-------------+ @@ -84,6 +85,7 @@ nebula> GO FROM "player102" OVER follow \ +----+--------+-----+ | id | Degree | Age | +----+--------+-----+ ++----+--------+-----+ ``` ## MINUS @@ -97,20 +99,20 @@ nebula> GO FROM "player102" OVER follow \ ### 示例 ```ngql -nebula> GO FROM "player100" OVER follow \ +nebula> GO FROM "player100" OVER follow YIELD dst(edge) \ MINUS \ - GO FROM "player102" OVER follow; + GO FROM "player102" OVER follow YIELD dst(edge); +-------------+ -| follow._dst | +| dst(EDGE) | +-------------+ | "player125" | +-------------+ -nebula> GO FROM "player102" OVER follow \ +nebula> GO FROM "player102" OVER follow YIELD dst(edge) \ MINUS \ - GO FROM "player100" OVER follow; + GO FROM "player100" OVER follow YIELD dst(edge); +-------------+ -| follow._dst | +| dst(EDGE) | +-------------+ | "player100" | +-------------+ diff --git a/docs-2.0/3.ngql-guide/6.functions-and-expressions/11.reduce.md b/docs-2.0/3.ngql-guide/6.functions-and-expressions/11.reduce.md index 11fcf825898..6bb811967ea 100644 --- a/docs-2.0/3.ngql-guide/6.functions-and-expressions/11.reduce.md +++ b/docs-2.0/3.ngql-guide/6.functions-and-expressions/11.reduce.md @@ -55,7 +55,7 @@ nebula> MATCH p = (n:player{name:"LeBron James"})<-[:follow]-(m) \ | 34 | 37 | 171 | +------+------+-----+ -nebula> LOOKUP ON player WHERE player.name == "Tony Parker" \ +nebula> LOOKUP ON player WHERE player.name == "Tony Parker" YIELD id(vertex) AS VertexID\ | GO FROM $-.VertexID over follow \ WHERE properties(edge).degree != reduce(totalNum = 5, n IN range(1, 3) | properties($$).age + totalNum + n) \ YIELD properties($$).name AS id, properties($$).age AS age, properties(edge).degree AS degree; diff --git a/docs-2.0/3.ngql-guide/6.functions-and-expressions/4.schema.md b/docs-2.0/3.ngql-guide/6.functions-and-expressions/4.schema.md index 4938afee29c..674f0f8bf21 100644 --- a/docs-2.0/3.ngql-guide/6.functions-and-expressions/4.schema.md +++ b/docs-2.0/3.ngql-guide/6.functions-and-expressions/4.schema.md @@ -46,14 +46,15 @@ nebula> GO FROM "player100" OVER follow REVERSELY \ | "player101" | | "player102" | +-------------+ +... nebula> LOOKUP ON player WHERE player.age > 45 YIELD id(vertex); -+-------------+-------------+ -| VertexID | id(VERTEX) | -+-------------+-------------+ -| "player144" | "player144" | -| "player140" | "player140" | -+-------------+-------------+ ++-------------+ +| id(VERTEX) | ++-------------+ +| "player144" | +| "player140" | ++-------------+ nebula> MATCH (a:player) WHERE id(a) == "player100" \ RETURN tags(a), labels(a), properties(a); diff --git a/docs-2.0/3.ngql-guide/7.general-query-statements/3.go.md b/docs-2.0/3.ngql-guide/7.general-query-statements/3.go.md index 94eab57fa90..4409c2815db 100644 --- a/docs-2.0/3.ngql-guide/7.general-query-statements/3.go.md +++ b/docs-2.0/3.ngql-guide/7.general-query-statements/3.go.md @@ -12,7 +12,7 @@ GO [[ TO] STEPS ] FROM OVER [{REVERSELY | BIDIRECT}] [ WHERE  ] -[YIELD [DISTINCT] ] +YIELD [DISTINCT] [{SAMPLE | LIMIT }] [| GROUP BY {col_name | expr | position} YIELD ] [| ORDER BY [{ASC | DESC}]] @@ -49,7 +49,7 @@ OVER [{REVERSELY | BIDIRECT}] 遍历多个 Edge type 时,`WHERE`子句有一些限制。例如不支持`WHERE edge1.prop1 > edge2.prop2`。 -- `YIELD [DISTINCT] `:定义需要返回的输出。` `建议使用 [Schema 函数](../6.functions-and-expressions/4.schema.md),当前支持`src(edge)`、`dst(edge)`、`type(edge)`、`rank(edge)`、`properties(edge)`、`id(vertex)`、`properties(vertex)`,暂不支持嵌套函数。详情参见 [YIELD](../8.clauses-and-options/yield.md)。如果没有指定,默认返回目的点 ID。 +- `YIELD [DISTINCT] `:定义需要返回的输出。` `建议使用 [Schema 函数](../6.functions-and-expressions/4.schema.md),当前支持`src(edge)`、`dst(edge)`、`type(edge)`等,暂不支持嵌套函数。详情参见 [YIELD](../8.clauses-and-options/yield.md)。 - `SAMPLE `:用于在结果集中取样。详情参见 [SAMPLE](../8.clauses-and-options/sample.md)。 @@ -69,25 +69,27 @@ OVER [{REVERSELY | BIDIRECT}] ```ngql # 返回 player102 所属队伍。 -nebula> GO FROM "player102" OVER serve; -+------------+ -| serve._dst | -+------------+ -| "team203" | -| "team204" | -+------------+ +nebula> GO FROM "player102" OVER serve YIELD dst(edge); ++-----------+ +| dst(EDGE) | ++-----------+ +| "team203" | +| "team204" | ++-----------+ ``` ```ngql # 返回距离 player102 两跳的朋友。 -nebula> GO 2 STEPS FROM "player102" OVER follow; +nebula> GO 2 STEPS FROM "player102" OVER follow YIELD dst(edge); +-------------+ -| follow._dst | +| dst(EDGE) | +-------------+ | "player101" | | "player125" | +| "player100" | +| "player102" | +| "player125" | +-------------+ -... ``` ```ngql @@ -113,6 +115,7 @@ nebula> GO FROM "player100" OVER follow, serve \ | properties(EDGE).degree | properties(EDGE).start_year | +-------------------------+-----------------------------+ | 95 | UNKNOWN_PROP | +| 95 | UNKNOWN_PROP | | UNKNOWN_PROP | 1997 | +-------------------------+-----------------------------+ ``` @@ -126,7 +129,6 @@ nebula> GO FROM "player100" OVER follow REVERSELY \ +-------------+ | "player101" | | "player102" | -+-------------+ ... # 该 MATCH 查询与上一个 GO 查询具有相同的语义。 @@ -137,7 +139,6 @@ nebula> MATCH (v)<-[e:follow]- (v2) WHERE id(v) == 'player100' \ +-------------+ | "player101" | | "player102" | -+-------------+ ... ``` diff --git a/docs-2.0/3.ngql-guide/7.general-query-statements/4.fetch.md b/docs-2.0/3.ngql-guide/7.general-query-statements/4.fetch.md index 73240230bea..edd9a833d1c 100644 --- a/docs-2.0/3.ngql-guide/7.general-query-statements/4.fetch.md +++ b/docs-2.0/3.ngql-guide/7.general-query-statements/4.fetch.md @@ -1,7 +1,5 @@ # FETCH - - `FETCH`可以获取指定点或边的属性值。 ## openCypher 兼容性 @@ -15,7 +13,7 @@ ```ngql FETCH PROP ON {[, tag_name ...] | *} [, vid ...] -[YIELD [AS ]]; +YIELD [AS ]; ``` |参数|说明| @@ -23,7 +21,7 @@ FETCH PROP ON {[, tag_name ...] | *} |`tag_name`|Tag 名称。| |`*`|表示当前图空间中的所有 Tag。| |`vid`|点 ID。| -|`YIELD`|定义需要返回的输出。除了返回定义的属性,额外返回`VertexID`。详情请参见 [`YIELD`](../8.clauses-and-options/yield.md)。如果没有`YIELD`子句,默认返回`vertices_`,包含点的所有信息。| +|`YIELD`|定义需要返回的输出。详情请参见 [`YIELD`](../8.clauses-and-options/yield.md)。| |`AS`| 设置别名。| ### 基于 Tag 获取点的属性值 @@ -31,12 +29,12 @@ FETCH PROP ON {[, tag_name ...] | *} 在`FETCH`语句中指定 Tag 获取对应点的属性值。 ```ngql -nebula> FETCH PROP ON player "player100"; -+----------------------------------------------------+ -| vertices_ | -+----------------------------------------------------+ -| ("player100" :player{age: 42, name: "Tim Duncan"}) | -+----------------------------------------------------+ +nebula> FETCH PROP ON player "player100" YIELD properties(vertex); ++-------------------------------+ +| properties(VERTEX) | ++-------------------------------+ +| {age: 42, name: "Tim Duncan"} | ++-------------------------------+ ``` ### 获取点的指定属性值 @@ -46,11 +44,11 @@ nebula> FETCH PROP ON player "player100"; ```ngql nebula> FETCH PROP ON player "player100" \ YIELD properties(vertex).name AS name; -+-------------+--------------+ -| VertexID | name | -+-------------+--------------+ -| "player100" | "Tim Duncan" | -+-------------+--------------+ ++--------------+ +| name | ++--------------+ +| "Tim Duncan" | ++--------------+ ``` ### 获取多个点的属性值 @@ -58,14 +56,14 @@ nebula> FETCH PROP ON player "player100" \ 指定多个点 ID 获取多个点的属性值,点之间用英文逗号(,)分隔。 ```ngql -nebula> FETCH PROP ON player "player101", "player102", "player103"; -+-----------------------------------------------------------+ -| vertices_ | -+-----------------------------------------------------------+ -| ("player101" :player{age: 36, name: "Tony Parker"}) | -| ("player102" :player{age: 33, name: "LaMarcus Aldridge"}) | -| ("player103" :player{age: 32, name: "Rudy Gay"}) | -+-----------------------------------------------------------+ +nebula> FETCH PROP ON player "player101", "player102", "player103" YIELD properties(vertex); ++--------------------------------------+ +| properties(VERTEX) | ++--------------------------------------+ +| {age: 33, name: "LaMarcus Aldridge"} | +| {age: 40, name: "Tony Parker"} | +| {age: 32, name: "Rudy Gay"} | ++--------------------------------------+ ``` ### 基于多个 Tag 获取点的属性值 @@ -77,25 +75,25 @@ nebula> FETCH PROP ON player "player101", "player102", "player103"; nebula> CREATE TAG IF NOT EXISTS t1(a string, b int); # 为点 player100 添加 Tag t1。 -nebula> INSERT VERTEX t1(a, b) VALUE "player100":("Hello", 100); +nebula> INSERT VERTEX t1(a, b) VALUES "player100":("Hello", 100); # 基于 Tag player 和 t1 获取点 player100 上的属性值。 -nebula> FETCH PROP ON player, t1 "player100"; +nebula> FETCH PROP ON player, t1 "player100" YIELD vertex AS v; +----------------------------------------------------------------------------+ -| vertices_ | +| v | +----------------------------------------------------------------------------+ -| ("player100" :t1{a: "Hello", b: 100} :player{age: 42, name: "Tim Duncan"}) | +| ("player100" :player{age: 42, name: "Tim Duncan"} :t1{a: "Hello", b: 100}) | +----------------------------------------------------------------------------+ ``` 用户可以在`FETCH`语句中组合多个 Tag 和多个点。 ```ngql -nebula> FETCH PROP ON player, t1 "player100", "player103"; +nebula> FETCH PROP ON player, t1 "player100", "player103" YIELD vertex AS v; +----------------------------------------------------------------------------+ -| vertices_ | +| v | +----------------------------------------------------------------------------+ -| ("player100" :t1{a: "Hello", b: 100} :player{age: 42, name: "Tim Duncan"}) | +| ("player100" :player{age: 42, name: "Tim Duncan"} :t1{a: "Hello", b: 100}) | | ("player103" :player{age: 32, name: "Rudy Gay"}) | +----------------------------------------------------------------------------+ ``` @@ -105,13 +103,13 @@ nebula> FETCH PROP ON player, t1 "player100", "player103"; 在`FETCH`语句中使用`*`获取当前图空间所有标签里,点的属性值。 ```ngql -nebula> FETCH PROP ON * "player100", "player106", "team200"; +nebula> FETCH PROP ON * "player100", "player106", "team200" YIELD vertex AS v; +----------------------------------------------------------------------------+ -| vertices_ | +| v | +----------------------------------------------------------------------------+ +| ("player100" :player{age: 42, name: "Tim Duncan"} :t1{a: "Hello", b: 100}) | | ("player106" :player{age: 25, name: "Kyle Anderson"}) | | ("team200" :team{name: "Warriors"}) | -| ("player100" :t1{a: "Hello", b: 100} :player{age: 42, name: "Tim Duncan"}) | +----------------------------------------------------------------------------+ ``` @@ -121,7 +119,7 @@ nebula> FETCH PROP ON * "player100", "player106", "team200"; ```ngql FETCH PROP ON -> [@] [, -> ...] -[YIELD ] +YIELD ; ``` |参数|说明| @@ -130,18 +128,18 @@ FETCH PROP ON -> [@] [, -> FETCH PROP ON serve "player100" -> "team204"; -+-----------------------------------------------------------------------+ -| edges_ | -+-----------------------------------------------------------------------+ -| [:serve "player100"->"team204" @0 {end_year: 2016, start_year: 1997}] | -+-----------------------------------------------------------------------+ +nebula> FETCH PROP ON serve "player100" -> "team204" YIELD properties(edge); ++------------------------------------+ +| properties(EDGE) | ++------------------------------------+ +| {end_year: 2016, start_year: 1997} | ++------------------------------------+ ``` ### 获取边的指定属性值 @@ -151,11 +149,11 @@ nebula> FETCH PROP ON serve "player100" -> "team204"; ```ngql nebula> FETCH PROP ON serve "player100" -> "team204" \ YIELD properties(edge).start_year; -+-------------+------------+-------------+-----------------------------+ -| serve._src | serve._dst | serve._rank | properties(EDGE).start_year | -+-------------+------------+-------------+-----------------------------+ -| "player100" | "team204" | 0 | 1997 | -+-------------+------------+-------------+-----------------------------+ ++-----------------------------+ +| properties(EDGE).start_year | ++-----------------------------+ +| 1997 | ++-----------------------------+ ``` ### 获取多条边的属性值 @@ -163,9 +161,9 @@ nebula> FETCH PROP ON serve "player100" -> "team204" \ 指定多个边模式 (` -> [@]`) 获取多个边的属性值。模式之间用英文逗号(,)分隔。 ```ngql -nebula> FETCH PROP ON serve "player100" -> "team204", "player133" -> "team202"; +nebula> FETCH PROP ON serve "player100" -> "team204", "player133" -> "team202" YIELD edge AS e; +-----------------------------------------------------------------------+ -| edges_ | +| e | +-----------------------------------------------------------------------+ | [:serve "player100"->"team204" @0 {end_year: 2016, start_year: 1997}] | | [:serve "player133"->"team202" @0 {end_year: 2011, start_year: 2002}] | @@ -185,17 +183,17 @@ nebula> insert edge serve(start_year,end_year) \ values "player100"->"team204"@2:(1990, 2018); # 默认返回 rank 为 0 的边。 -nebula> FETCH PROP ON serve "player100" -> "team204"; +nebula> FETCH PROP ON serve "player100" -> "team204" YIELD edge AS e; +-----------------------------------------------------------------------+ -| edges_ | +| e | +-----------------------------------------------------------------------+ | [:serve "player100"->"team204" @0 {end_year: 2016, start_year: 1997}] | +-----------------------------------------------------------------------+ # 要获取 rank 不为 0 的边,请在 FETCH 语句中设置 rank。 -nebula> FETCH PROP ON serve "player100" -> "team204"@1; +nebula> FETCH PROP ON serve "player100" -> "team204"@1 YIELD edge AS e; +-----------------------------------------------------------------------+ -| edges_ | +| e | +-----------------------------------------------------------------------+ | [:serve "player100"->"team204" @1 {end_year: 2017, start_year: 1998}] | +-----------------------------------------------------------------------+ @@ -211,13 +209,13 @@ nebula> GO FROM "player101" OVER follow \ YIELD src(edge) AS s, dst(edge) AS d \ | FETCH PROP ON follow $-.s -> $-.d \ YIELD properties(edge).degree; -+-------------+-------------+--------------+-------------------------+ -| follow._src | follow._dst | follow._rank | properties(EDGE).degree | -+-------------+-------------+--------------+-------------------------+ -| "player101" | "player100" | 0 | 95 | -| "player101" | "player102" | 0 | 90 | -| "player101" | "player125" | 0 | 95 | -+-------------+-------------+--------------+-------------------------+ ++-------------------------+ +| properties(EDGE).degree | ++-------------------------+ +| 95 | +| 90 | +| 95 | ++-------------------------+ ``` 用户也可以通过自定义变量构建类似的查询。 @@ -227,13 +225,13 @@ nebula> $var = GO FROM "player101" OVER follow \ YIELD src(edge) AS s, dst(edge) AS d; \ FETCH PROP ON follow $var.s -> $var.d \ YIELD properties(edge).degree; -+-------------+-------------+--------------+-------------------------+ -| follow._src | follow._dst | follow._rank | properties(EDGE).degree | -+-------------+-------------+--------------+-------------------------+ -| "player101" | "player100" | 0 | 95 | -| "player101" | "player102" | 0 | 90 | -| "player101" | "player125" | 0 | 95 | -+-------------+-------------+--------------+-------------------------+ ++-------------------------+ +| properties(EDGE).degree | ++-------------------------+ +| 95 | +| 90 | +| 95 | ++-------------------------+ ``` 更多复合语句的详情,请参见[复合查询(子句结构)](../4.variable-and-composite-queries/1.composite-queries.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 a18fd9e54a5..c054574976f 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 @@ -1,7 +1,5 @@ # LOOKUP - - `LOOKUP`根据索引遍历数据。用户可以使用`LOOKUP`实现如下功能: - 根据`WHERE`子句搜索特定数据。 @@ -37,7 +35,7 @@ ```ngql LOOKUP ON { | } [WHERE [AND ...]] -[YIELD [AS ]]; +YIELD [AS ]; [AS ] [, [AS ] ...]; @@ -45,10 +43,7 @@ LOOKUP ON { | } - `WHERE `:指定遍历的过滤条件,还可以结合布尔运算符 AND 和 OR 一起使用。详情请参见 [WHERE](../8.clauses-and-options/where.md)。 -- `YIELD`:定义需要返回的输出。 - - - `LOOKUP`Tag 时,除了返回定义的属性,额外返回`VertexID`。如果没有`YIELD`子句,返回`VertexID`。 - - `LOOKUP`Edge type 时,除了返回定义的属性,额外返回`起始点 ID`、`目的点 ID`和`rank`。如果没有`YIELD`子句,返回`起始点 ID`、`目的点 ID`和`rank`。 +- `YIELD`:定义需要返回的输出。详情请参见 [`YIELD`](../8.clauses-and-options/yield.md)。 - `AS`:设置别名。 @@ -77,45 +72,50 @@ nebula> REBUILD TAG INDEX index_player; +------------+ nebula> LOOKUP ON player \ - WHERE player.name == "Tony Parker"; -+-------------+ -| VertexID | -+-------------+ -| "player101" | -+-------------+ + WHERE player.name == "Tony Parker" \ + YIELD id(vertex); ++---------------+ +| id(VERTEX) | ++---------------+ +| "player101" | ++---------------+ nebula> LOOKUP ON player \ WHERE player.name == "Tony Parker" \ YIELD properties(vertex).name AS name, properties(vertex).age AS age; -+-------------+---------------+-----+ -| VertexID | name | age | -+-------------+---------------+-----+ -| "player101" | "Tony Parker" | 36 | -+-------------+---------------+-----+ ++---------------+-----+ +| name | age | ++---------------+-----+ +| "Tony Parker" | 36 | ++---------------+-----+ nebula> LOOKUP ON player \ - WHERE player.age > 45; + WHERE player.age > 45 \ + YIELD id(vertex); +-------------+ -| VertexID | +| id(VERTEX) | +-------------+ -| "player140" | | "player144" | +| "player140" | +| "player111" | +-------------+ nebula> LOOKUP ON player \ WHERE player.name STARTS WITH "B" \ AND player.age IN [22,30] \ YIELD properties(vertex).name, properties(vertex).age; -+-------------+-------------------------+------------------------+ -| VertexID | properties(VERTEX).name | properties(VERTEX).age | -+-------------+-------------------------+------------------------+ -| "player134" | "Blake Griffin" | 30 | -| "player149" | "Ben Simmons" | 22 | -+-------------+-------------------------+------------------------+ ++-------------------------+------------------------+ +| properties(VERTEX).name | properties(VERTEX).age | ++-------------------------+------------------------+ +| "Blake Griffin" | 30 | +| "Ben Simmons" | 22 | +| "Blake Griffin" | 30 | +| "Ben Simmons" | 22 | ++-------------------------+------------------------+ nebula> LOOKUP ON player \ WHERE player.name == "Kobe Bryant"\ - YIELD properties(vertex).name AS name |\ + YIELD id(vertex) AS VertexID, properties(vertex).name AS name |\ GO FROM $-.VertexID OVER serve \ YIELD $-.name, properties(edge).start_year, properties(edge).end_year, properties($$).name; +---------------+-----------------------------+---------------------------+---------------------+ @@ -140,13 +140,13 @@ nebula> REBUILD EDGE INDEX index_follow; +------------+ nebula> LOOKUP ON follow \ - WHERE follow.degree == 90; -+-------------+-------------+---------+ -| SrcVID | DstVID | Ranking | -+-------------+-------------+---------+ -| "player150" | "player143" | 0 | -| "player150" | "player137" | 0 | -| "player148" | "player136" | 0 | + WHERE follow.degree == 90 YIELD edge AS e; ++----------------------------------------------------+ +| e | ++----------------------------------------------------+ +| [:follow "player109"->"player125" @0 {degree: 90}] | +| [:follow "player118"->"player120" @0 {degree: 90}] | +| [:follow "player118"->"player131" @0 {degree: 90}] | ... nebula> LOOKUP ON follow \ @@ -162,16 +162,16 @@ nebula> LOOKUP ON follow \ nebula> LOOKUP ON follow \ WHERE follow.degree == 60 \ - YIELD properties(edge).degree AS Degree |\ + YIELD dst(edge) AS DstVID, properties(edge).degree AS Degree |\ GO FROM $-.DstVID OVER serve \ YIELD $-.DstVID, properties(edge).start_year, properties(edge).end_year, properties($$).name; -+-------------+------------------------------+---------------------------+---------------------+ -| $-.DstVID | properties(EDGE).start_year | properties(EDGE).end_year | properties($$).name | -+-------------+------------------------------+---------------------------+---------------------+ -| "player105" | 2010 | 2018 | "Spurs" | -| "player105" | 2009 | 2010 | "Cavaliers" | -| "player105" | 2018 | 2019 | "Raptors" | -+-------------+------------------------------+---------------------------+---------------------+ ++-------------+-----------------------------+---------------------------+---------------------+ +| $-.DstVID | properties(EDGE).start_year | properties(EDGE).end_year | properties($$).name | ++-------------+-----------------------------+---------------------------+---------------------+ +| "player105" | 2010 | 2018 | "Spurs" | +| "player105" | 2009 | 2010 | "Cavaliers" | +| "player105" | 2018 | 2019 | "Raptors" | ++-------------+-----------------------------+---------------------------+---------------------+ ``` ## 通过 Tag 列出所有的对应的点/通过 Edge type 列出边 @@ -199,13 +199,13 @@ nebula> LOOKUP ON follow \ # 列出所有的 player。类似于 MATCH (n:player) RETURN id(n) /*, n */。 - nebula> LOOKUP ON player; + nebula> LOOKUP ON player YIELD id(vertex); +-------------+ - | VertexID | + | id(VERTEX) | +-------------+ | "player100" | | "player101" | - +-------------+ + ... ``` - 查找 Edge type 为`follow`的所有边的信息。 @@ -227,12 +227,14 @@ nebula> LOOKUP ON follow \ # 列出所有的 follow 边。类似于 MATCH (s)-[e:follow]->(d) RETURN id(s), rank(e), id(d) /*, type(e) */。 - nebula)> LOOKUP ON follow; - +-------------+-------------+---------+ - | SrcVID | DstVID | Ranking | - +-------------+-------------+---------+ - | "player100" | "player101" | 0 | - +-------------+-------------+---------+ + nebula)> LOOKUP ON follow YIELD edge AS e; + +-----------------------------------------------------+ + | e | + +-----------------------------------------------------+ + | [:follow "player105"->"player100" @0 {degree: 70}] | + | [:follow "player105"->"player116" @0 {degree: 80}] | + | [:follow "player109"->"player100" @0 {degree: 80}] | + ... ``` ## 统计点或边 @@ -240,7 +242,7 @@ nebula> LOOKUP ON follow \ 统计 Tag 为`player`的点和 Edge type 为`follow`的边。 ```ngql -nebula> LOOKUP ON player |\ +nebula> LOOKUP ON player YIELD id(vertex)|\ YIELD COUNT(*) AS Player_Number; +---------------+ | Player_Number | @@ -248,7 +250,7 @@ nebula> LOOKUP ON player |\ | 51 | +---------------+ -nebula> LOOKUP ON follow | \ +nebula> LOOKUP ON follow YIELD edge AS e| \ YIELD COUNT(*) AS Follow_Number; +---------------+ | Follow_Number | diff --git a/docs-2.0/3.ngql-guide/8.clauses-and-options/limit.md b/docs-2.0/3.ngql-guide/8.clauses-and-options/limit.md index dc4962085cd..2dab4c77aef 100644 --- a/docs-2.0/3.ngql-guide/8.clauses-and-options/limit.md +++ b/docs-2.0/3.ngql-guide/8.clauses-and-options/limit.md @@ -35,10 +35,10 @@ ```ngql # 从结果中返回最前面的 3 行数据。 -nebula> LOOKUP ON player |\ +nebula> LOOKUP ON player YIELD id(vertex)|\ LIMIT 3; +-------------+ -| VertexID | +| id(VERTEX) | +-------------+ | "player100" | | "player101" | @@ -92,16 +92,17 @@ nebula> GO 3 STEPS FROM "player100" \ | "Manu Ginobili" | 41 | +-----------------+--------------+ -nebula> GO 3 STEPS FROM "player102" \ - OVER * \ +nebula> GO 3 STEPS FROM "player102" OVER * \ + YIELD dst(edge) \ LIMIT [rand32(5),rand32(5),rand32(5)]; -+------------+-------------+ -| serve._dst | follow._dst | -+------------+-------------+ -| "team204" | | -| "team215" | | -| | "player100" | -+------------+-------------+ ++-------------+ +| dst(EDGE) | ++-------------+ +| "team204" | +| "team215" | +| "player100" | +| "player102" | ++-------------+ ``` ## openCypher 兼容语句中的 LIMIT diff --git a/docs-2.0/3.ngql-guide/8.clauses-and-options/order-by.md b/docs-2.0/3.ngql-guide/8.clauses-and-options/order-by.md index 50e6bcff1f9..cb292966ada 100644 --- a/docs-2.0/3.ngql-guide/8.clauses-and-options/order-by.md +++ b/docs-2.0/3.ngql-guide/8.clauses-and-options/order-by.md @@ -28,14 +28,14 @@ ORDER BY [ASC | DESC] [, [ASC | DESC] ...]; nebula> FETCH PROP ON player "player100", "player101", "player102", "player103" \ YIELD properties(vertex).age AS age, properties(vertex).name AS name \ | ORDER BY $-.age ASC, $-.name DESC; -+-------------+-----+---------------------+ -| VertexID | age | name | -+-------------+-----+---------------------+ -| "player103" | 32 | "Rudy Gay" | -| "player102" | 33 | "LaMarcus Aldridge" | -| "player101" | 36 | "Tony Parker" | -| "player100" | 42 | "Tim Duncan" | -+-------------+-----+---------------------+ ++-----+---------------------+ +| age | name | ++-----+---------------------+ +| 32 | "Rudy Gay" | +| 33 | "LaMarcus Aldridge" | +| 36 | "Tony Parker" | +| 42 | "Tim Duncan" | ++-----+---------------------+ nebula> $var = GO FROM "player100" OVER follow \ YIELD dst(edge) AS dst; \ diff --git a/docs-2.0/3.ngql-guide/8.clauses-and-options/where.md b/docs-2.0/3.ngql-guide/8.clauses-and-options/where.md index 555b1162c63..49b204699a1 100644 --- a/docs-2.0/3.ngql-guide/8.clauses-and-options/where.md +++ b/docs-2.0/3.ngql-guide/8.clauses-and-options/where.md @@ -75,11 +75,11 @@ nebula> GO FROM "player100" \ ``` ```ngql - nebula> GO FROM "player100" \ - OVER follow \ - WHERE $^.player.age >= 42; + nebula> GO FROM "player100" OVER follow \ + WHERE $^.player.age >= 42 \ + YIELD dst(edge); +-------------+ - | follow._dst | + | dst(EDGE) | +-------------+ | "player101" | | "player125" | @@ -105,11 +105,11 @@ nebula> GO FROM "player100" \ ``` ```ngql - nebula> GO FROM "player100" \ - OVER follow \ - WHERE follow.degree > 90; + nebula> GO FROM "player100" OVER follow \ + WHERE follow.degree > 90 \ + YIELD dst(edge); +-------------+ - | follow._dst | + | dst(EDGE) | +-------------+ | "player101" | | "player125" | @@ -305,15 +305,15 @@ nebula> MATCH (v:player) \ nebula> LOOKUP ON player \ WHERE player.age IN [25,28] \ YIELD properties(vertex).name, properties(vertex).age; -+-------------+-------------------------+------------------------+ -| VertexID | properties(VERTEX).name | properties(VERTEX).age | -+-------------+-------------------------+------------------------+ -| "player106" | "Kyle Anderson" | 25 | -| "player135" | "Damian Lillard" | 28 | -| "player130" | "Joel Embiid" | 25 | -| "player131" | "Paul George" | 28 | -| "player123" | "Ricky Rubio" | 28 | -+-------------+-------------------------+------------------------+ ++-------------------------+------------------------+ +| properties(VERTEX).name | properties(VERTEX).age | ++-------------------------+------------------------+ +| "Kyle Anderson" | 25 | +| "Damian Lillard" | 28 | +| "Joel Embiid" | 25 | +| "Paul George" | 28 | +| "Ricky Rubio" | 28 | ++-------------------------+------------------------+ ``` ### 结合 NOT 使用 diff --git a/docs-2.0/3.ngql-guide/8.clauses-and-options/yield.md b/docs-2.0/3.ngql-guide/8.clauses-and-options/yield.md index da41af5ce17..9c33e99694c 100644 --- a/docs-2.0/3.ngql-guide/8.clauses-and-options/yield.md +++ b/docs-2.0/3.ngql-guide/8.clauses-and-options/yield.md @@ -4,7 +4,7 @@ `YIELD`可以引导子句或语句: -- `YIELD`子句可以用于原生 nGQL 语句中,例如`GO`、`FETCH`或`LOOKUP`。 +- `YIELD`子句用于原生 nGQL 语句中,例如`GO`、`FETCH`或`LOOKUP`,必须通过`YIELD`子句定义返回结果。 - `YIELD`语句可以在独立查询或复合查询中使用。 @@ -59,11 +59,11 @@ YIELD [DISTINCT] [AS ] [, [AS ] ...]; ```ngql nebula> FETCH PROP ON player "player100" \ YIELD properties(vertex).name; - +-------------+-------------------------+ - | VertexID | properties(VERTEX).name | - +-------------+-------------------------+ - | "player100" | "Tim Duncan" | - +-------------+-------------------------+ + +-------------------------+ + | properties(VERTEX).name | + +-------------------------+ + | "Tim Duncan" | + +-------------------------+ ``` - `LOOKUP`语句中使用`YIELD`: @@ -71,11 +71,11 @@ YIELD [DISTINCT] [AS ] [, [AS ] ...]; ```ngql nebula> LOOKUP ON player WHERE player.name == "Tony Parker" \ YIELD properties(vertex).name, properties(vertex).age; - +-------------+-------------------------+------------------------+ - | VertexID | properties(VERTEX).name | properties(VERTEX).age | - +-------------+-------------------------+------------------------+ - | "player101" | "Tony Parker" | 36 | - +-------------+-------------------------+------------------------+ + +-------------------------+------------------------+ + | properties(VERTEX).name | properties(VERTEX).age | + +-------------------------+------------------------+ + | "Tony Parker" | 36 | + +-------------------------+------------------------+ ``` ## YIELD 语句 diff --git a/docs-2.0/nebula-studio/use-console/st-ug-visualize-subgraph.md b/docs-2.0/nebula-studio/use-console/st-ug-visualize-subgraph.md index c1e63fbd28c..84d7108ff8a 100644 --- a/docs-2.0/nebula-studio/use-console/st-ug-visualize-subgraph.md +++ b/docs-2.0/nebula-studio/use-console/st-ug-visualize-subgraph.md @@ -33,7 +33,7 @@ Studio v{{ studio.release }} 及以后版本。请更新版本,详细操作参 查询语句示例如下: ```nGQL - nebula> FIND ALL PATH FROM "player114" to "player100" OVER follow; + nebula> FIND ALL PATH FROM "player114" to "player100" OVER follow YIELD path AS p; ``` 查询得到如下图所示路径信息。 diff --git a/docs-2.0/reuse/source_connect-to-nebula-graph.md b/docs-2.0/reuse/source_connect-to-nebula-graph.md index a30247d91e1..27bca556ebc 100644 --- a/docs-2.0/reuse/source_connect-to-nebula-graph.md +++ b/docs-2.0/reuse/source_connect-to-nebula-graph.md @@ -150,9 +150,9 @@ nebula> :repeat N ```ngql nebula> :repeat 3 -nebula> GO FROM "player100" OVER follow; +nebula> GO FROM "player100" OVER follow YIELD dst(edge); +-------------+ -| follow._dst | +| dst(EDGE) | +-------------+ | "player101" | | "player125" | @@ -162,7 +162,7 @@ Got 2 rows (time spent 2602/3214 us) Fri, 20 Aug 2021 06:36:05 UTC +-------------+ -| follow._dst | +| dst(EDGE) | +-------------+ | "player101" | | "player125" | @@ -172,7 +172,7 @@ Got 2 rows (time spent 583/849 us) Fri, 20 Aug 2021 06:36:05 UTC +-------------+ -| follow._dst | +| dst(EDGE) | +-------------+ | "player101" | | "player125" | From 98ec73f3f986889093fe142887ffcd1410a80e79 Mon Sep 17 00:00:00 2001 From: cooper-lzy <78672629+cooper-lzy@users.noreply.github.com> Date: Tue, 7 Dec 2021 10:06:55 +0800 Subject: [PATCH 2/3] Update 11.reduce.md --- docs-2.0/3.ngql-guide/6.functions-and-expressions/11.reduce.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs-2.0/3.ngql-guide/6.functions-and-expressions/11.reduce.md b/docs-2.0/3.ngql-guide/6.functions-and-expressions/11.reduce.md index 6bb811967ea..dbb759418e7 100644 --- a/docs-2.0/3.ngql-guide/6.functions-and-expressions/11.reduce.md +++ b/docs-2.0/3.ngql-guide/6.functions-and-expressions/11.reduce.md @@ -55,7 +55,7 @@ nebula> MATCH p = (n:player{name:"LeBron James"})<-[:follow]-(m) \ | 34 | 37 | 171 | +------+------+-----+ -nebula> LOOKUP ON player WHERE player.name == "Tony Parker" YIELD id(vertex) AS VertexID\ +nebula> LOOKUP ON player WHERE player.name == "Tony Parker" YIELD id(vertex) AS VertexID \ | GO FROM $-.VertexID over follow \ WHERE properties(edge).degree != reduce(totalNum = 5, n IN range(1, 3) | properties($$).age + totalNum + n) \ YIELD properties($$).name AS id, properties($$).age AS age, properties(edge).degree AS degree; From a918dc4d632f971ce89b601d58697eee047d577a Mon Sep 17 00:00:00 2001 From: cooper-lzy <78672629+cooper-lzy@users.noreply.github.com> Date: Tue, 7 Dec 2021 10:08:41 +0800 Subject: [PATCH 3/3] Update 4.schema.md --- docs-2.0/3.ngql-guide/6.functions-and-expressions/4.schema.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs-2.0/3.ngql-guide/6.functions-and-expressions/4.schema.md b/docs-2.0/3.ngql-guide/6.functions-and-expressions/4.schema.md index 674f0f8bf21..fd2bf959019 100644 --- a/docs-2.0/3.ngql-guide/6.functions-and-expressions/4.schema.md +++ b/docs-2.0/3.ngql-guide/6.functions-and-expressions/4.schema.md @@ -45,7 +45,6 @@ nebula> GO FROM "player100" OVER follow REVERSELY \ +-------------+ | "player101" | | "player102" | -+-------------+ ... nebula> LOOKUP ON player WHERE player.age > 45 YIELD id(vertex);