From ef030710188e355a58d514065ed9fd1bdd8f0151 Mon Sep 17 00:00:00 2001 From: Abby <78209557+abby-cyber@users.noreply.github.com> Date: Thu, 5 May 2022 15:19:08 +0800 Subject: [PATCH] Update 6.cheatsheet-for-ngql.md --- docs-2.0/2.quick-start/6.cheatsheet-for-ngql.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs-2.0/2.quick-start/6.cheatsheet-for-ngql.md b/docs-2.0/2.quick-start/6.cheatsheet-for-ngql.md index 1b56ec5a6da..cb4aa291cb9 100644 --- a/docs-2.0/2.quick-start/6.cheatsheet-for-ngql.md +++ b/docs-2.0/2.quick-start/6.cheatsheet-for-ngql.md @@ -233,8 +233,8 @@ | Match multiple VIDs. | `MATCH (v:player { name: 'Tim Duncan' })--(v2) WHERE id(v2) IN ["player101", "player102"] RETURN v2` | To match multiple VIDs, use `WHERE id(v) IN [vid_list]`. | | Match connected vertices | `MATCH (v:player{name:"Tim Duncan"})--(v2) RETURN v2.player.name AS Name` | You can use the `--` symbol to represent edges of both directions and match vertices connected by these edges. You can add a `>` or `<` to the `--` symbol to specify the direction of an edge. | | Match paths | `MATCH p=(v:player{name:"Tim Duncan"})-->(v2) RETURN p` | Connected vertices and edges form a path. You can use a user-defined variable to name a path as follows. | - | Match edges | `MATCH (v:player{name:"Tim Duncan"})-[e]-(v2) RETURN e` | Besides using `--`, `-->`, or `<--` to indicate a nameless edge, you can use a user-defined variable in a pair of square brackets to represent a named edge. For example: `-[e]-`. | - | Match an edge type | `MATCH ()-[e:follow]-() RETURN e` |Just like vertices, you can specify an edge type with `:` in a pattern. For example: `-[e:follow]-`. | + | Match edges | `MATCH (v:player{name:"Tim Duncan"})-[e]-(v2) RETURN e`
`MATCH ()<-[e]-() RETURN e LIMIT 3` | Besides using `--`, `-->`, or `<--` to indicate a nameless edge, you can use a user-defined variable in a pair of square brackets to represent a named edge. For example: `-[e]-`. | + | Match an edge type | `MATCH ()-[e:follow]-() RETURN e LIMIT 5` |Just like vertices, you can specify an edge type with `:` in a pattern. For example: `-[e:follow]-`. | | Match edge type properties | ` MATCH (v:player{name:"Tim Duncan"})-[e:follow{degree:95}]->(v2) RETURN e` | You can specify edge type properties with `{: }` in a pattern. For example: `[e:follow{likeness:95}]`. | | Match multiple edge types | `MATCH (v:player{name:"Tim Duncan"})-[e:follow | :serve]->(v2) RETURN e` | The `|` symbol can help matching multiple edge types. For example: `[e:follow|:serve]`. The English colon (:) before the first edge type cannot be omitted, but the English colon before the subsequent edge type can be omitted, such as `[e:follow|serve]`. | | Match multiple edges | `MATCH (v:player{name:"Tim Duncan"})-[]->(v2)<-[e:serve]-(v3) RETURN v2, v3` | You can extend a pattern to match multiple edges in a path. | @@ -250,7 +250,7 @@ | Retrieve paths | `MATCH p=(v:player{name:"Tim Duncan"})-[*3]->() RETURN p` | Use `RETURN ` to retrieve all the information of the matched paths. | | Retrieve vertices in a path | `MATCH p=(v:player{name:"Tim Duncan"})-[]->(v2) RETURN nodes(p)` | Use the `nodes()` function to retrieve all vertices in a path. | | Retrieve edges in a path | `MATCH p=(v:player{name:"Tim Duncan"})-[]->(v2) RETURN relationships(p)` | Use the `relationships()` function to retrieve all edges in a path. | - | Retrieve path length | `MATCH p=(v:player{name:"Tim Duncan">})-[*..2]->(v2) RETURN p AS Paths, length(p) AS Length` | Use the `length()` function to retrieve the length of a path. | + | Retrieve path length | `MATCH p=(v:player{name:"Tim Duncan"})-[*..2]->(v2) RETURN p AS Paths, length(p) AS Length` | Use the `length()` function to retrieve the length of a path. | * [OPTIONAL MATCH](../3.ngql-guide/7.general-query-statements/optional-match.md) @@ -364,7 +364,7 @@ | Clause | Syntax | Example | Description | | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | | [GROUP BY](../3.ngql-guide/8.clauses-and-options/group-by.md) | ` GROUP BY YIELD , ` | `GO FROM "player100" OVER follow BIDIRECT YIELD $$.player.name as Name | GROUP BY $-.Name YIELD $-.Name as Player, count(*) AS Name_Count` | Finds all the vertices connected directly to vertex `"player100"`, groups the result set by player names, and counts how many times the name shows up in the result set. | -| [LIMIT](../3.ngql-guide/8.clauses-and-options/limit.md) | `YIELD [| LIMIT [,] ]` | `O FROM "player100" OVER follow REVERSELY YIELD $$.player.name AS Friend, $$.player.age AS Age | ORDER BY $-.Age, $-.Friend | LIMIT 1, 3` | Returns the 3 rows of data starting from the second row of the sorted output. | +| [LIMIT](../3.ngql-guide/8.clauses-and-options/limit.md) | `YIELD [| LIMIT [,] ]` | `GO FROM "player100" OVER follow REVERSELY YIELD $$.player.name AS Friend, $$.player.age AS Age | ORDER BY $-.Age, $-.Friend | LIMIT 1, 3` | Returns the 3 rows of data starting from the second row of the sorted output. | | [SKIP](../3.ngql-guide/8.clauses-and-options/limit.md) | `RETURN [SKIP ] [LIMIT ]` | `MATCH (v:player{name:"Tim Duncan"}) --> (v2) RETURN v2.player.name AS Name, v2.player.age AS Age ORDER BY Age DESC SKIP 1` | `SKIP` can be used alone to set the offset and return the data after the specified position. | | [SAMPLE](../3.ngql-guide/8.clauses-and-options/sample.md) | ` SAMPLE ;` | `GO 3 STEPS FROM "player100" OVER * YIELD properties($$).name AS NAME, properties($$).age AS Age SAMPLE [1,2,3];` | Takes samples evenly in the result set and returns the specified amount of data. | | [ORDER BY](../3.ngql-guide/8.clauses-and-options/order-by.md) | ` ORDER BY [ASC | DESC] [, [ASC | DESC] ...]` | `FETCH PROP ON player "player100", "player101", "player102", "player103" YIELD player.age AS age, player.name AS name | ORDER BY $-.age ASC, $-.name DESC` | The `ORDER BY` clause specifies the order of the rows in the output. |