Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 6.cheatsheet-for-ngql.md #1325

Merged
merged 1 commit into from
May 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs-2.0/2.quick-start/6.cheatsheet-for-ngql.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `:<edge_type>` in a pattern. For example: `-[e:follow]-`. |
| Match edges | `MATCH (v:player{name:"Tim Duncan"})-[e]-(v2) RETURN e`<br>`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 `:<edge_type>` 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 `{<prop_name>: <prop_value>}` 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. |
Expand All @@ -250,7 +250,7 @@
| Retrieve paths | `MATCH p=(v:player{name:"Tim Duncan"})-[*3]->() RETURN p` | Use `RETURN <path_name>` 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)

Expand Down Expand Up @@ -364,7 +364,7 @@
| Clause | Syntax | Example | Description |
| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| [GROUP BY](../3.ngql-guide/8.clauses-and-options/group-by.md) | ` GROUP BY <var> YIELD <var>, <aggregation_function(var)>` | `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 <var> [| LIMIT [<offset_value>,] <number_rows>]` | `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 <var> [| LIMIT [<offset_value>,] <number_rows>]` | `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 <var> [SKIP <offset>] [LIMIT <number_rows>]` | `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) | `<go_statement> SAMPLE <sample_list>;` | `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) | `<YIELD clause> ORDER BY <expression> [ASC | DESC] [, <expression> [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. |
Expand Down