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 f6b64c141be..9598736b323 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 @@ Users can use the `INSERT` statement to insert vertices or edges based on existi 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 @@ Users can use the `INSERT` statement to insert vertices or edges based on existi ```ngql FETCH PROP ON {[, tag_name ...] | *} [, vid ...] - [YIELD [AS ]]; + YIELD [AS ]; ``` * Fetch properties on edges: ```ngql FETCH PROP ON -> [@] [, -> ...] - [YIELD ]; + YIELD ; ``` * `LOOKUP` @@ -277,7 +277,7 @@ Users can use the `INSERT` statement to insert vertices or edges based on existi ```ngql LOOKUP ON { | } [WHERE [AND ...]] - [YIELD [AS ]]; + YIELD [AS ]; ``` * `MATCH` @@ -291,12 +291,13 @@ Users can use the `INSERT` statement to insert vertices or edges based on existi * Search for the players that the player with VID `player101` follows. ```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 @@ Users can use the `INSERT` statement to insert vertices or edges based on existi ```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 | + +-----------------+-----+ ``` | Clause/Sign | Description | @@ -329,7 +331,10 @@ Users can use the `INSERT` statement to insert vertices or edges based on existi +-----------------+---------------------+ | Team | Player | +-----------------+---------------------+ + | "Spurs" | "Tim Duncan" | | "Trail Blazers" | "LaMarcus Aldridge" | + | "Spurs" | "LaMarcus Aldridge" | + | "Spurs" | "Manu Ginobili" | +-----------------+---------------------+ ``` @@ -352,7 +357,10 @@ Users can use the `INSERT` statement to insert vertices or edges based on existi +-----------------+---------------------+ | Team | Player | +-----------------+---------------------+ + | "Spurs" | "Tim Duncan" | | "Trail Blazers" | "LaMarcus Aldridge" | + | "Spurs" | "LaMarcus Aldridge" | + | "Spurs" | "Manu Ginobili" | +-----------------+---------------------+ ``` @@ -361,12 +369,12 @@ Users can use the `INSERT` statement to insert vertices or edges based on existi Use `FETCH`: Fetch the properties of the player with 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 @@ Users can use the `UPDATE` or the `UPSERT` statements to update existing data. ```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` the `degree` property of an edge and check the result with the `FETCH` statement. @@ -426,12 +434,12 @@ Users can use the `UPDATE` or the `UPSERT` statements to update existing data. ```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 a vertex with VID `player111` and `UPSERT` it. @@ -518,7 +526,7 @@ Find the information of the vertex with the tag `player` and its value of the `n This example creates the index `player_index_1` on the player name property. ```nGQL -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)); ``` This example rebuilds the index to make sure it takes effect on pre-existing data. @@ -538,11 +546,11 @@ This example uses the `LOOKUP` statement to retrieve the vertex property. ```nGQL 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 | ++---------------+-----+ ``` This example uses the `MATCH` statement to retrieve the vertex property. 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 f043389276f..007749b0110 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,27 +28,25 @@ 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 63bf3ddbab5..3c71ed8484c 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,10 @@ 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 +40,9 @@ nebula> LOOKUP ON shareholder; //In this example, the "player100" is no longer a shareholder. 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 8a8bb3dd5f2..c48d924f150 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 @@ A vertex can be inserted/written with new values multiple times. Only the last w 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); # In the following example, the value of p3 is the default 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__} | ++---------------------------------+ # In the following example, the allowed maximum length of p1 is 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 you insert a vertex that already exists with `IF NOT EXISTS`, there will be no modification. @@ -120,10 +120,10 @@ If you insert a vertex that already exists with `IF NOT EXISTS`, there will be n nebula> INSERT VERTEX t2 (name, age) VALUES "1":("n2", 13); # Modify vertex "1" with IF NOT EXISTS. But there will be no modification as vertex "1" already exists. 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 afb3d7069a9..ef75ee3a3c5 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 // This query checks the properties of vertex "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"} | ++--------------------------------+ // This query updates the age property and returns name and the new 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 6ba81d422e3..0abce44476a 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,11 +56,11 @@ Here are some examples: ```ngql // This query checks if the following three vertices exist. The result "Empty set" indicates that the vertices do not exist. -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" \ @@ -124,12 +124,12 @@ nebula> UPSERT VERTEX ON player_with_default "player101" \ If the vertex exists and the `WHEN` conditions are met, the vertex is updated. ```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 \ @@ -138,19 +138,19 @@ nebula> UPSERT VERTEX ON player "player101" \ +---------------+-----+ | Name | Age | +---------------+-----+ -| "Tony Parker" | 44 | +| "Tony Parker" | 38 | +---------------+-----+ ``` If the vertex exists and the `WHEN` conditions are not met, the update does not take effect. ```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 \ @@ -159,6 +159,6 @@ nebula> UPSERT VERTEX ON player "player101" \ +---------------+-----+ | Name | Age | +---------------+-----+ -| "Tony Parker" | 44 | +| "Tony Parker" | 38 | +---------------+-----+ ``` 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 a187f40bd12..614e0971861 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 @@ The following examples insert edge e2 with the new values for multiple times. 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 @@ If you insert an edge that already exists with `IF NOT EXISTS`, there will be no nebula> INSERT EDGE e2 (name, age) VALUES "14"->"15"@1:("n1", 12); # The following example alters the edge with IF NOT EXISTS. But there will be no alteration because edge e2 already 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 dacb35f1b6d..badcef4c176 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 @@ -57,7 +57,11 @@ Here are some examples: // This example checks if the following three vertices have any outgoing serve edge. The result "Empty set" indicates that such an edge does not exist. nebula> GO FROM "player666", "player667", "player668" \ OVER serve \ - YIELD serve.start_year, serve.end_year; + 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 c284145986b..f391ae5e308 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); // These examples run test queries. -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,28 +149,26 @@ 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" | -| "Russell Westbrook" | -+---------------------+ ... nebula> LOOKUP ON player WHERE FUZZY(player.name, "Tim Dunncan", AUTO, OR) YIELD player.name; -+--------------+--------------+ -| _vid | name | -+--------------+--------------+ -| "Tim Duncan" | "Tim Duncan" | -+--------------+--------------+ ++--------------+ +| name | ++--------------+ +| "Tim Duncan" | ++--------------+ // This example drops the full-text index. 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 fdc9370e02a..1ee2e8af61d 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,8 @@ To show the completeness of the subgraph, an additional hop is made on all verti If you only query paths or vertices that meet the conditions, we suggest you use [MATCH](../7.general-query-statements/2.match.md) or [GO](../7.general-query-statements/3.go.md). The example is as follows. ```ngql -nebula> match p= (v:player) -- (v2) where id(v)=="A" return p; - -nebula> go 1 steps from "A" over follow; +nebula> MATCH p= (v:player) -- (v2) WHERE id(v)=="A" RETURN p; +nebula> GO 1 STEPS FROM "A" OVER follow YIELD id(vertex); ``` ### Why is the number of hops in the returned result lower than `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 2a2bf0b760c..1478997a5ea 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] [ A returned path is like `()-[:@]->( 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 e6e6f09679e..78332734fc6 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"); Query the vertex `Kobe`. The property `age` is `18` by default. ```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 7f12a148173..ef0fbd1b54a 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 @@ One major difference between nGQL and SQL is how sub-queries are composed. ```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 9cd4a5a2d96..9331c508e25 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 @@ Set operators apply to native nGQL only. ```ngql # The following statement returns the union of two query results without duplicated elements. -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 \ +-------------+ # The following statement returns the union of two query results with duplicated elements. -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" | +-------------+ @@ -98,20 +99,20 @@ Operator `MINUS` returns the subtraction (or difference) of two sets A and B (de ### Example ```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); +-------------+ -| dst(edge) | +| 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 4fbbddc03a7..ac923064b37 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 @@ -57,7 +57,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 3387b957b63..0081677864d 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,14 +45,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 f58366e64d6..f9157202a23 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 @@ This topic applies to native nGQL only. 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}] There are some restrictions for the `WHERE` clause when you traverse along with multiple edge types. For example, `WHERE edge1.prop1 > edge2.prop2` is not supported. -- `YIELD [DISTINCT] `: defines the output to be returned. It is recommended to use the [Schema function](../6.functions-and-expressions/4.schema.md) to fill in ``. `src(edge)`, `dst(edge)`, `type(edge) )`, `rank(edge)`, `properties(edge)`, `id(vertex)`, and `properties(vertex)` are currently supported, while nested functions are not. For more information, see [YIELD](../8.clauses-and-options/yield.md). When not specified, the destination vertex ID of the edge will be returned by default. +- `YIELD [DISTINCT] `: defines the output to be returned. It is recommended to use the [Schema function](../6.functions-and-expressions/4.schema.md) to fill in ``. `src(edge)`, `dst(edge)`, `type(edge) )`, `rank(edge)`, etc., are currently supported, while nested functions are not. For more information, see [YIELD](../8.clauses-and-options/yield.md). - `SAMPLE `: takes samples from the result set. For more information, see [SAMPLE](../8.clauses-and-options/sample.md). @@ -69,25 +69,27 @@ OVER [{REVERSELY | BIDIRECT}] ```ngql # The following example returns the teams that player 102 serves. -nebula> GO FROM "player102" OVER serve; -+------------+ -| serve._dst | -+------------+ -| "team203" | -| "team204" | -+------------+ +nebula> GO FROM "player102" OVER serve YIELD dst(edge); ++-----------+ +| dst(EDGE) | ++-----------+ +| "team203" | +| "team204" | ++-----------+ ``` ```ngql # The following example returns the friends of player 102 with 2 hops. -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 @@ -127,7 +129,6 @@ nebula> GO FROM "player100" OVER follow REVERSELY \ +-------------+ | "player101" | | "player102" | -+-------------+ ... # This MATCH query shares the same semantics with the preceding GO query. 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 34b4aea1384..2f1d92af875 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 @@ -15,7 +15,7 @@ This topic applies to native nGQL only. ```ngql FETCH PROP ON {[, tag_name ...] | *} [, vid ...] -[YIELD [AS ]]; +YIELD [AS ]; ``` | Parameter | Description | @@ -23,7 +23,7 @@ FETCH PROP ON {[, tag_name ...] | *} | `tag_name` | The name of the tag. | | `*` | Represents all the tags in the current graph space. | | `vid` | The vertex ID. | -| `YIELD` | Define the output to be returned. The defined properties and `VertexID` are returned. For details, see [`YIELD`](../8.clauses-and-options/yield.md). If there is no `YIELD` clause, `vertices_` is returned by default, which contains all the information about the vertex. | +| `YIELD` | Define the output to be returned. For details, see [`YIELD`](../8.clauses-and-options/yield.md). | | `AS` | Set an alias. | ### Fetch vertex properties by one tag @@ -31,12 +31,12 @@ FETCH PROP ON {[, tag_name ...] | *} Specify a tag in the `FETCH` statement to fetch the vertex properties by that 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"} | ++-------------------------------+ ``` ### Fetch specific properties of a vertex @@ -46,11 +46,11 @@ Use a `YIELD` clause to specify the properties to be returned. ```ngql nebula> FETCH PROP ON player "player100" \ YIELD properties(vertex).name AS name; -+-------------+--------------+ -| VertexID | name | -+-------------+--------------+ -| "player100" | "Tim Duncan" | -+-------------+--------------+ ++--------------+ +| name | ++--------------+ +| "Tim Duncan" | ++--------------+ ``` ### Fetch properties of multiple vertices @@ -58,14 +58,14 @@ nebula> FETCH PROP ON player "player100" \ Specify multiple VIDs (vertex IDs) to fetch properties of multiple vertices. Separate the VIDs with commas. ```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"} | ++--------------------------------------+ ``` ### Fetch vertex properties by multiple tags @@ -77,25 +77,25 @@ Specify multiple tags in the `FETCH` statement to fetch the vertex properties by nebula> CREATE TAG IF NOT EXISTS t1(a string, b int); # The following example attaches t1 to the vertex "player100". -nebula> INSERT VERTEX t1(a, b) VALUE "player100":("Hello", 100); +nebula> INSERT VERTEX t1(a, b) VALUES "player100":("Hello", 100); # The following example fetches the properties of vertex "player100" by the tags player and t1. -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}) | +----------------------------------------------------------------------------+ ``` You can combine multiple tags with multiple VIDs in a `FETCH` statement. ```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 +105,13 @@ nebula> FETCH PROP ON player, t1 "player100", "player103"; Set an asterisk symbol `*` to fetch properties by all tags in the current graph space. ```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 +121,7 @@ nebula> FETCH PROP ON * "player100", "player106", "team200"; ```ngql FETCH PROP ON -> [@] [, -> ...] -[YIELD ] +YIELD ; ``` | Parameter | Description | @@ -130,19 +130,19 @@ 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} | ++------------------------------------+ ``` ### Fetch specific properties of an edge @@ -152,11 +152,11 @@ Use a `YIELD` clause to fetch specific properties of an edge. ```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 | ++-----------------------------+ ``` ### Fetch properties of multiple edges @@ -164,9 +164,9 @@ nebula> FETCH PROP ON serve "player100" -> "team204" \ Specify multiple edge patterns (` -> [@]`) to fetch properties of multiple edges. Separate the edge patterns with commas. ```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}] | @@ -186,17 +186,17 @@ nebula> insert edge serve(start_year,end_year) \ values "player100"->"team204"@2:(1990, 2018); # By default, the FETCH statement returns the edge whose rank is 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}] | +-----------------------------------------------------------------------+ # To fetch on an edge whose rank is not 0, set its rank in the FETCH statement. -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}] | +-----------------------------------------------------------------------+ @@ -213,13 +213,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 | ++-------------------------+ ``` Or you can use user-defined variables to construct similar queries. @@ -229,13 +229,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 | ++-------------------------+ ``` For more information about composite queries, see [Composite queries (clause structure)](../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 f055273e382..63ab6494335 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 @@ -37,7 +37,7 @@ Before using the `LOOKUP` statement, make sure that at least one index is create ```ngql LOOKUP ON { | } [WHERE [AND ...]] -[YIELD [AS ]]; +YIELD [AS ]; [AS ] [, [AS ] ...]; @@ -45,10 +45,7 @@ LOOKUP ON { | } - `WHERE `: filters data with specified conditions. Both `AND` and `OR` are supported between different expressions. For more information, see [WHERE](../8.clauses-and-options/where.md). -- `YIELD`: Define the output to be returned. - - - When you `LOOKUP` a Tag, the defined properties and `VertexID` are returned. If there is no `YIELD` clause, `VertexID` is returned. - - When you `LOOKUP` an Edge type, the defined properties, `SrcVertexID`, `DstVertexID`, and `rank` are returned. If there is no `YIELD` clause, `SrcVertexID`, `DstVertexID`, and `rank` are returned. +- `YIELD`: Define the output to be returned. For details, see [`YIELD`](../8.clauses-and-options/yield.md). - `AS`: Set an alias. @@ -77,45 +74,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 +142,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 +164,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 | serve.start_year | serve.end_year | $$.team.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" | ++-------------+-----------------------------+---------------------------+---------------------+ ``` ## List vertices or edges with a tag or an edge type @@ -199,13 +201,13 @@ For example, if there is a `player` tag with a `name` property and an `age` prop The following statement retrieves the VID of all vertices with the tag `player`. It is similar to `MATCH (n:player) RETURN id(n) /*, n */`. - nebula> LOOKUP ON player; + nebula> LOOKUP ON player YIELD id(vertex); +-------------+ - | VertexID | + | id(VERTEX) | +-------------+ | "player100" | | "player101" | - +-------------+ + ... ``` - The following example shows how to retrieve the source Vertex IDs, destination vertex IDs, and ranks of all edges of the `follow` edge type. @@ -227,12 +229,14 @@ For example, if there is a `player` tag with a `name` property and an `age` prop The following statement retrieves all edges with the edge type `follow`. It is similar to `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}] | + ... ``` ## Count the numbers of vertices or edges @@ -240,7 +244,7 @@ For example, if there is a `player` tag with a `name` property and an `age` prop The following example shows how to count the number of vertices tagged with `player` and edges of the `follow` edge type. ```ngql -nebula> LOOKUP ON player |\ +nebula> LOOKUP ON player YIELD id(vertex)|\ YIELD COUNT(*) AS Player_Number; +---------------+ | Player_Number | @@ -248,7 +252,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 3fa07e84cdf..9fa34d01d9c 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 @@ For example: ```ngql # The following example returns the top 3 rows of data from the result. -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 | any_shape_edge._dst | -+------------+-------------+---------------------+ -| "team204" | | | -| "team215" | | | -| | "player100" | | -+------------+-------------+---------------------+ ++-------------+ +| dst(EDGE) | ++-------------+ +| "team204" | +| "team215" | +| "player100" | +| "player102" | ++-------------+ ``` ## LIMIT in openCypher compatible statements 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 ed80cda1925..73a219a06f0 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 player.age AS age, player.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 fb0d7594e87..550cae32d26 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,12 @@ Use vertex or edge properties to define conditions in `WHERE` clauses. ``` ```ngql - nebula> GO FROM "player100" \ - OVER follow \ - WHERE $^.player.age >= 42; + nebula> GO FROM "player100" OVER follow \ + WHERE $^.player.age >= 42 \ + YIELD dst(edge); + +-------------+ + | dst(EDGE) | +-------------+ - | follow._dst | +-------------+ | "player101" | | "player125" | @@ -105,11 +106,11 @@ Use vertex or edge properties to define conditions in `WHERE` clauses. ``` ```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" | @@ -309,15 +310,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 | ++-------------------------+------------------------+ ``` ### Match values not in a list 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 4b1858cf33a..079149b3750 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` can lead a clause or a statement: -* A `YIELD` clause works in nGQL statements such as `GO`, `FETCH`, or `LOOKUP`. +* A `YIELD` clause works in nGQL statements such as `GO`, `FETCH`, or `LOOKUP` and must be defined to return the result. * A `YIELD` statement works in a composite query or independently. @@ -59,11 +59,11 @@ YIELD [DISTINCT] [AS ] [, [AS ] ...]; ```ngql nebula> FETCH PROP ON player "player100" \ YIELD properties(vertex).name; - +-------------+-------------------------+ - | VertexID | properties(VERTEX).name | - +-------------+-------------------------+ - | "player100" | UNKNOWN_PROP | - +-------------+-------------------------+ + +-------------------------+ + | properties(VERTEX).name | + +-------------------------+ + | "Tim Duncan" | + +-------------------------+ ``` * Use `YIELD` with `LOOKUP`: @@ -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 statements 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 8465100b765..67136da0907 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 @@ To query the paths or subgraph on the **Console** page and then view them on the Here is an nGQL statement example. ```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; ``` Take the `FIND ALL PATH` for example, query the path information as shown in this figure. 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 be66883cdbc..21f56ab3b50 100644 --- a/docs-2.0/reuse/source_connect-to-nebula-graph.md +++ b/docs-2.0/reuse/source_connect-to-nebula-graph.md @@ -149,9 +149,9 @@ For example, ```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" | @@ -161,7 +161,7 @@ Got 2 rows (time spent 2602/3214 us) Fri, 20 Aug 2021 06:36:05 UTC +-------------+ -| follow._dst | +| dst(EDGE) | +-------------+ | "player101" | | "player125" | @@ -171,7 +171,7 @@ Got 2 rows (time spent 583/849 us) Fri, 20 Aug 2021 06:36:05 UTC +-------------+ -| follow._dst | +| dst(EDGE) | +-------------+ | "player101" | | "player125" |