Skip to content

Commit

Permalink
[use manual] add more manuals (#742)
Browse files Browse the repository at this point in the history
* 1. add group_by
2. add property reference
3. mv nebula 127 ..> to nebula>

* address judy & amber's comments

* add fetch

* add order by
  • Loading branch information
whitewum authored and dutor committed Aug 13, 2019
1 parent 414d582 commit d128868
Show file tree
Hide file tree
Showing 27 changed files with 290 additions and 107 deletions.
58 changes: 29 additions & 29 deletions docs/get-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ To connect to the graph server, run
Welcome to Nebula Graph (Version 0.1)
(user@127.0.0.1) [(none)]>
nebula>
```

If you have any questions or concerns about the deployment procedures, please do not hesitate to open an issue on [GitHub](https://github.com/vesoft-inc/nebula/issues).
Expand Down Expand Up @@ -291,15 +291,15 @@ There are three kinds of tags (_course_, _building_ and _student_) and two edge

To list all existing spaces:
```
(user@127.0.0.1) [(none)]> SHOW SPACES;
nebula> SHOW SPACES;
```

To create a new space named myspace_test2 :
```
(user@127.0.0.1) [(none)]> CREATE SPACE myspace_test2(partition_num=1, replica_factor=1);
nebula> CREATE SPACE myspace_test2(partition_num=1, replica_factor=1);
-- Use this space
(user@127.0.0.1) [(none)]> USE myspace_test2;
nebula> USE myspace_test2;
```
`replica_factor` specifies the number of replicas in the cluster.

Expand All @@ -309,32 +309,32 @@ To create a new space named myspace_test2 :

The `CREATE TAG` statement defines a tag, with a type name and an attribute list.
```
(user@127.0.0.1) [(none)]> CREATE TAG course(name string, credits int);
(user@127.0.0.1) [(none)]> CREATE TAG building(name string);
(user@127.0.0.1) [(none)]> CREATE TAG student(name string, age int, gender string);
nebula> CREATE TAG course(name string, credits int);
nebula> CREATE TAG building(name string);
nebula> CREATE TAG student(name string, age int, gender string);
```
The `CREATE EDGE` statement defines an edge type.
```
(user@127.0.0.1) [(none)]> CREATE EDGE like(likeness double);
(user@127.0.0.1) [(none)]> CREATE EDGE select(grade int);
nebula> CREATE EDGE like(likeness double);
nebula> CREATE EDGE select(grade int);
```

To list the tags and edge types that we just created:
```
-- Show tag list
(user@127.0.0.1) [(none)]> SHOW TAGS;
nebula> SHOW TAGS;
-- Show edge type list
(user@127.0.0.1) [(none)]> SHOW EDGES;
nebula> SHOW EDGES;
```

To show the attributes of a tag or an edge type:
```
-- Show attributes of a tag
(user@127.0.0.1) [(none)]> DESCRIBE TAG student;
nebula> DESCRIBE TAG student;
-- Show attributes of an edge type
(user@127.0.0.1) [(none)]> DESCRIBE EDGE like;
nebula> DESCRIBE EDGE like;
```


Expand All @@ -345,31 +345,31 @@ Insert the vertices and edges based on the graph above.
```
-- Insert vertices
(user@127.0.0.1) [(none)]> INSERT VERTEX student(name, age, gender) VALUES 200:("Monica", 16, "female");
(user@127.0.0.1) [(none)]> INSERT VERTEX student(name, age, gender) VALUES 201:("Mike", 18, "male");
(user@127.0.0.1) [(none)]> INSERT VERTEX student(name, age, gender) VALUES 202:("Jane", 17, "female");
(user@127.0.0.1) [(none)]> INSERT VERTEX course(name, credits),building(name) VALUES 101:("Math", 3, "No5");
(user@127.0.0.1) [(none)]> INSERT VERTEX course(name, credits),building(name) VALUES 102:("English", 6, "No11");
nebula> INSERT VERTEX student(name, age, gender) VALUES 200:("Monica", 16, "female");
nebula> INSERT VERTEX student(name, age, gender) VALUES 201:("Mike", 18, "male");
nebula> INSERT VERTEX student(name, age, gender) VALUES 202:("Jane", 17, "female");
nebula> INSERT VERTEX course(name, credits),building(name) VALUES 101:("Math", 3, "No5");
nebula> INSERT VERTEX course(name, credits),building(name) VALUES 102:("English", 6, "No11");
```

```
-- Insert edges
(user@127.0.0.1) [(none)]> INSERT EDGE select(grade) VALUES 200 -> 101:(5);
(user@127.0.0.1) [(none)]> INSERT EDGE select(grade) VALUES 200 -> 102:(3);
(user@127.0.0.1) [(none)]> INSERT EDGE select(grade) VALUES 201 -> 102:(3);
(user@127.0.0.1) [(none)]> INSERT EDGE select(grade) VALUES 202 -> 102:(3);
(user@127.0.0.1) [(none)]> INSERT EDGE like(likeness) VALUES 200 -> 201:(92.5);
(user@127.0.0.1) [(none)]> INSERT EDGE like(likeness) VALUES 201 -> 200:(85.6);
(user@127.0.0.1) [(none)]> INSERT EDGE like(likeness) VALUES 201 -> 202:(93.2);
nebula> INSERT EDGE select(grade) VALUES 200 -> 101:(5);
nebula> INSERT EDGE select(grade) VALUES 200 -> 102:(3);
nebula> INSERT EDGE select(grade) VALUES 201 -> 102:(3);
nebula> INSERT EDGE select(grade) VALUES 202 -> 102:(3);
nebula> INSERT EDGE like(likeness) VALUES 200 -> 201:(92.5);
nebula> INSERT EDGE like(likeness) VALUES 201 -> 200:(85.6);
nebula> INSERT EDGE like(likeness) VALUES 201 -> 202:(93.2);
```

## Sample Queries

Q1. Find the vertexes that 201 likes:

```
(user@127.0.0.1) [(none)]> GO FROM 201 OVER like;
nebula> GO FROM 201 OVER like;
=======
| id |
Expand All @@ -383,7 +383,7 @@ Q1. Find the vertexes that 201 likes:
Q2. Find the vertexes that 201 likes, whose age are greater than 17. Return their name, age and gender, and alias the columns as Friend, Age and Gender, respectively.

```
(user@127.0.0.1) [(none)]> GO FROM 201 OVER like WHERE $$.student.age >= 17 YIELD $$.student.name AS Friend, $$.student.age AS Age, $$.student.gender AS Gender;
nebula> GO FROM 201 OVER like WHERE $$.student.age >= 17 YIELD $$.student.name AS Friend, $$.student.age AS Age, $$.student.gender AS Gender;
=========================
| Friend | Age | Gender |
Expand All @@ -402,7 +402,7 @@ Q3. Find the selected courses and corresponding grades of students liked by 201.
```
-- By pipe
(user@127.0.0.1) [(none)]> GO FROM 201 OVER like | GO FROM $-.id OVER select YIELD $^.student.name AS Student, $$.course.name AS Course, select.grade AS Grade;
nebula> GO FROM 201 OVER like | GO FROM $-.id OVER select YIELD $^.student.name AS Student, $$.course.name AS Course, select.grade AS Grade;
=============================
| Student | Course | Grade |
Expand All @@ -415,7 +415,7 @@ Q3. Find the selected courses and corresponding grades of students liked by 201.
-----------------------------
-- By temporary variable
(user@127.0.0.1) [(none)]> $a=GO FROM 201 OVER like; GO FROM $a.id OVER select YIELD $^.student.name AS Student, $$.course.name AS Course, select.grade AS Grade;
nebula> $a=GO FROM 201 OVER like; GO FROM $a.id OVER select YIELD $^.student.name AS Student, $$.course.name AS Course, select.grade AS Grade;
=============================
| Student | Course | Grade |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ Comparison operations result in a value of _true_ and _false_.
Equal. String comparisons are case-sensitive. Values of different type are not equal.

```
(user@127.0.0.1) [(none)]> YIELD 'A' == 'a';
nebula> YIELD 'A' == 'a';
==============
| ("A"=="a") |
==============
| false |
--------------
(user@127.0.0.1) [(none)]> YIELD '2' == 2;
nebula> YIELD '2' == 2;
============
| ("2"==2) |
============
Expand All @@ -40,7 +40,7 @@ Equal. String comparisons are case-sensitive. Values of different type are not e
Greater than:

```
(user@127.0.0.1) [(none)]> YIELD 3 > 2;
nebula> YIELD 3 > 2;
=========
| (3>2) |
=========
Expand All @@ -53,7 +53,7 @@ Greater than:
Greater than or equal:

```
(user@127.0.0.1) [(none)]> YIELD 2 >= 2;
nebula> YIELD 2 >= 2;
==========
| (2>=2) |
==========
Expand All @@ -66,7 +66,7 @@ Greater than or equal:
Less than:

```
(user@127.0.0.1) [(none)]> YIELD 2.0 < 1.9;
nebula> YIELD 2.0 < 1.9;
=======================
| (2.000000<1.900000) |
=======================
Expand All @@ -79,7 +79,7 @@ Less than:
Less than or equal:

```
(user@127.0.0.1) [(none)]> YIELD 0.11 <= 0.11;
nebula> YIELD 0.11 <= 0.11;
========================
| (0.110000<=0.110000) |
========================
Expand All @@ -92,7 +92,7 @@ Less than or equal:
Not equal:

```
(user@127.0.0.1) [(none)]> YIELD 1 != '1'
nebula> YIELD 1 != '1'
============
| (1!="1") |
============
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
| Name | Description |
| ***Name*** | ***Description*** |
|:----|:----:|
| abs() | Return the absolute value |
| acos() | Return the arc cosine |
Expand Down
26 changes: 26 additions & 0 deletions docs/manual_doc/Functions_and_Operators/Group_By_Function.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

# Aggregate (Group by) function

The `GROUP BY` functions are similar with SQL. It can only be applied in the `YIELD`-syntax.

|Name | Description |
|:----|:----:|
| AVG() | Return the average value of the argument |
| COUNT() | Return the number of records |
| COUNT(DISTINCT) | Return the number of different values |
| MAX() | Return the maximum value |
| MIN() | Return the minimum value |
| STD() | Return the population standard deviation |
| SUM() | Return the sum |

All the functions above can only applies for int64 and double.

### example

```
nebula> GO FROM 1 OVER e1 | YIELD $-.id AS fid, COUNT(*) AS cnt GROUP BY fid
-- for each fid, return the occurrence count.
nebula> GO FROM 1 YIELD e1._dst AS fid, e1.prop1 AS prop1 | YIELD fid, SUM(prop1) GROUP BY fid
-- for each fid, return the sum of prop1.
```
8 changes: 4 additions & 4 deletions docs/manual_doc/Functions_and_Operators/Logical_Operators.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
| Name | Description |
| ***Name*** | ***Description*** |
|:----|:----:|
| && | Logical AND |
| ! | Logical NOT |
Expand All @@ -12,7 +12,7 @@ In nGQL, nonzero numbers are evaluated to _true_. The precedence of the operator
Logical AND:

```
(user@127.0.0.1) [(none)]> YIELD -1 && true;
nebula> YIELD -1 && true;
================
| (-(1)&&true) |
================
Expand All @@ -25,7 +25,7 @@ Logical AND:
Logical NOT:

```
(user@127.0.0.1) [(none)]> YIELD !(-1);
nebula> YIELD !(-1);
===========
| !(-(1)) |
===========
Expand All @@ -39,7 +39,7 @@ Logical NOT:
Logical OR:

```
(user@127.0.0.1) [(none)]> YIELD 1 || !1;
nebula> YIELD 1 || !1;
=============
| (1||!(1)) |
=============
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ For operators from the same precedence level within an expression, evaluation is
Examples:

```
(user@127.0.0.1) [(none)]> YIELD 2+3*5;
(user@127.0.0.1) [(none)]> YIELD (2+3)*5;
nebula> YIELD 2+3*5;
nebula> YIELD (2+3)*5;
```

22 changes: 22 additions & 0 deletions docs/manual_doc/Functions_and_Operators/Order_By_Function.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Order By Function

Similar with SQL, `ORDER BY` can be used to sort in ascending (`ASC`) or descending (`DESC`) order for return results.
And it can only be used in the `PIEP`-syntax ("|")

```
| ORDER BY <prop> ASC | DESC [, <prop> ASC | DESC ...]
```
By default, `ORDER BY` sorts in ascending order if no ASC or DESC is given.

### Example

```
nebula> FETCH PROP ON player 1,2,3,4 YIELD player.age AS age, player.weight as weight | ORDER BY $-.age, $-.weight DESC
-- get four of vertices and sort by their age begin with the youngest one, and for those with the same age, sort by their weight.
```
(see `FETCH` for the usage)

```
nebula> GO FROM 1 OVER edge2 YIELD $^.t1.prop1 AS s1_p1, edge2.prop2 AS e2_p2, $$.t3.prop3 AS d3_p3 | ORDER BY s1_p1 ASC, e2_p2 DESC, d3_p3 ASC
```
For a group of returned tuples <s1_p1, e2_p2, d3_p3>, first sort in ascending order of s1_p1, then in descending order of e2_p2, finally ascending order of d3_p3.
2 changes: 2 additions & 0 deletions docs/manual_doc/Functions_and_Operators/Type_Conversion.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
<!---
Not supported yet
--->
17 changes: 9 additions & 8 deletions docs/manual_doc/Language_Structure/Comment_Syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ Nested comments are not supported
The following example demonstrates all these comment styles:

```
(user@127.0.0.1) [(none)]> YIELD 1+1 # This comment continues to the end of line
(user@127.0.0.1) [(none)]> YIELD 1+1 -- This comment continues to the end of line
(user@127.0.0.1) [(none)]> YIELD 1+1 // This comment continues to the end of line
(user@127.0.0.1) [(none)]> YIELD 1 /* this is an in-line comment */ + 1
(user@127.0.0.1) [(none)]> YIELD 11 + \
/* Multiple-line comment \
Use backslash \
as line break. \
nebula> -- Do nothing this line
nebula> YIELD 1+1 # This comment continues to the end of line
nebula> YIELD 1+1 -- This comment continues to the end of line
nebula> YIELD 1+1 // This comment continues to the end of line
nebula> YIELD 1 /* this is an in-line comment */ + 1
nebula> YIELD 11 + \
/* Multiple-line comment \
Use backslash as line break. \
*/ 12
```
The backslash `\` at the line of line indicates a line break.

Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ In Nebula Graph, Identifiers are case-sensitive.
The following statement would not work because it refers to a space both as 'my_space' and as 'MY_SPACE':

```
(user@127.0.0.1) [(none)]> CREATE SPACE my_space();
(user@127.0.0.1) [(none)]> use MY_SPACE;
nebula> CREATE SPACE my_space();
nebula> use MY_SPACE;
```

However, keywords and reserved words are case-insensitive.

The following statements are equivalent:
```
(user@127.0.0.1) [(none)]> show spaces;
(user@127.0.0.1) [(none)]> SHOW SPACES;
(user@127.0.0.1) [(none)]> SHOW spaces;
(user@127.0.0.1) [(none)]> show spaces;
nebula> show spaces;
nebula> SHOW SPACES;
nebula> SHOW spaces;
nebula> show spaces;
```
Empty file.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
The boolean literals `TRUE` and `FALSE` can be written in any lettercase.

```
(user@127.0.0.1) [(none)]> yield TRUE, true, FALSE, false, FalsE
nebula> yield TRUE, true, FALSE, false, FalsE
=========================================
|  true |  true | false | false | false |  
=========================================
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!---
>NOTICE: NULL and NOT NULL are NOT FULLY SUPPORTED YET!
The NULL value means “no data.” NULL can be written in any lettercase. Be aware that the NULL value is different from values such as 0 for interges or empty string.
The NULL value means “no data.” NULL can be written in any letter cases. Be aware that the NULL value is different from values such as 0 for interges or empty string.
--->
Loading

0 comments on commit d128868

Please sign in to comment.