diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 487e2b5f9b9..e67a307a206 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,11 +6,11 @@ 可以从以下方面进行贡献: -- 修正拼写错误或格式(标点,空格,缩进,代码块等) -- 修正或更新不适当或过时的描述 -- 提交新文档 -- 提交或解决文档[issues](https://github.com/vesoft-inc/nebula-docs-cn/issues) -- 审阅他人提交的 PR +- 修正拼写错误或格式(标点,空格,缩进,代码块等)。 +- 修正或更新不适当或过时的描述。 +- 提交新文档。 +- 提交或解决文档 [issue][_issues]。 +- 审阅他人提交的 PR。 ## 必须遵循的 Markdown 规范 @@ -22,5 +22,8 @@ 可以选择以下方式进行贡献: -- 在 [GitHub](https://github.com/vesoft-inc/nebula-docs-cn/issues) 提交 issue。 -- Fork 文档,在本地分支上更改或添加新内容,然后向主分支提交 PR。 +- 在 GitHub 提交 [issue][_issues]。 +- [Fork](https://github.com/vesoft-inc/nebula-docs-cn/fork) 文档,在本地分支上更改或添加新内容,然后向主分支提交 PR。 + + +[_issues]: https://github.com/vesoft-inc/nebula-docs-cn/issues diff --git a/docs-2.0/1.introduction/1.what-is-nebula-graph.md b/docs-2.0/1.introduction/1.what-is-nebula-graph.md index ff79971438d..6b8773df679 100644 --- a/docs-2.0/1.introduction/1.what-is-nebula-graph.md +++ b/docs-2.0/1.introduction/1.what-is-nebula-graph.md @@ -38,7 +38,7 @@ Nebula Graph支持严格的角色访问控制和LDAP(Lightweight Directory Acc ### 生态多样化 -Nebula Graph开放了越来越多的原生工具,例如[Nebula Graph Studio](https://github.com/vesoft-inc/nebula-studio)、[Nebula Console](https://github.com/vesoft-inc/nebula-console)、[Nebula Exchange](https://github.com/vesoft-inc/nebula-spark-utils/tree/v2.0.0/nebula-exchange)等,更多工具可以查看 [生态工具概览](../20.appendix/6.eco-tool-version.md)。 +Nebula Graph开放了越来越多的原生工具,例如[Nebula Graph Studio](https://github.com/vesoft-inc/nebula-studio)、[Nebula Console](https://github.com/vesoft-inc/nebula-console)、[Nebula Exchange](https://github.com/vesoft-inc/nebula-exchange)等,更多工具可以查看 [生态工具概览](../20.appendix/6.eco-tool-version.md)。 此外,Nebula Graph还具备与Spark、Flink、HBase等产品整合的能力,在这个充满挑战与机遇的时代,大大增强了自身的竞争力。 diff --git a/docs-2.0/1.introduction/2.data-model.md b/docs-2.0/1.introduction/2.data-model.md index a84bc961318..c78e42b6554 100644 --- a/docs-2.0/1.introduction/2.data-model.md +++ b/docs-2.0/1.introduction/2.data-model.md @@ -1,12 +1,12 @@ # 数据模型 -本文介绍Nebula Graph的数据模型。数据模型是一种组织数据并说明它们如何相互关联的模型(schema)。 +本文介绍Nebula Graph的数据模型。数据模型是一种组织数据并说明它们如何相互关联的模型(schema)。 ## 数据模型 Nebula Graph数据模型使用6种基本的数据模型: -- 图空间(Space) +- 图空间(Space) 图空间用于隔离不同团队或者项目的数据。不同图空间的数据是相互隔离的,可以指定不同的存储副本数、权限、分片等。 @@ -14,7 +14,7 @@ Nebula Graph数据模型使用6种基本的数据模型: 点用来保存实体对象,特点如下: - - 点是用点标识符(`VID`)标识的。`VID`在同一图空间中唯一。VID 是一个 int64, 或者 fixed_string(N)。 + - 点是用点标识符(`VID`)标识的。`VID`在同一图空间中唯一。VID 是一个 int64,或者 fixed_string(N)。 - 点必须有至少一个Tag,也可以有多个Tag。但不能没有Tag。 - 边(Edge) @@ -25,7 +25,7 @@ Nebula Graph数据模型使用6种基本的数据模型: - 边是有方向的,不存在无向边。 - 四元组 `<起点VID、Edge type、边排序值(Rank)、终点VID>` 用于唯一标识一条边。边没有EID。 - 一条边有且仅有一个Edge type。 - - 一条边有且仅有一个rank。其为int64, 默认为0。 + - 一条边有且仅有一个rank。其为int64,默认为0。 - 标签(Tag) @@ -51,10 +51,10 @@ Nebula Graph使用有向属性图模型,指点和边构成的图,这些边 | 类型 | 名称 | 属性名(数据类型) | 说明 | | :--- | :--- | :---| :--- | -|Tag| **player** | name (string)
age (int) | 表示球员。 | -|Tag| **team** | name (string) | 表示球队。 | -|Edge type| **serve** | start_year (int)
end_year (int) | 表示球员的行为。
该行为将球员和球队联系起来,方向是从球员到球队。 | -|Edge type| **follow** | degree(int) | 表示球员的行为。
该行为将两个球员联系起来,方向是从一个球员到另一个球员。 | +|Tag| **player** | name (string)
age(int) | 表示球员。 | +|Tag| **team** | name (string) | 表示球队。 | +|Edge type| **serve** | start_year (int)
end_year (int) | 表示球员的行为。
该行为将球员和球队联系起来,方向是从球员到球队。 | +|Edge type| **follow** | degree (int) | 表示球员的行为。
该行为将两个球员联系起来,方向是从一个球员到另一个球员。 | !!! Note @@ -62,6 +62,6 @@ Nebula Graph使用有向属性图模型,指点和边构成的图,这些边 !!! compatibility - 由于 Nebula Graph {{ nebula.release }} 的数据模型中,允许存在"悬挂边",因此在增删时,用户需自行保证“一条边所对应的起点和终点”的存在性。详见[INSERT VERTEX](../3.ngql-guide/12.vertex-statements/1.insert-vertex.md), [DELETE VERTEX](../3.ngql-guide/12.vertex-statements/4.delete-vertex.md), [INSERT EDGE](../3.ngql-guide/13.edge-statements/1.insert-edge.md), [DELETE EDGE](../3.ngql-guide/13.edge-statements/4.delete-edge.md)。 + 由于 Nebula Graph {{ nebula.release }} 的数据模型中,允许存在"悬挂边",因此在增删时,用户需自行保证“一条边所对应的起点和终点”的存在性。详见[INSERT VERTEX](../3.ngql-guide/12.vertex-statements/1.insert-vertex.md)、[DELETE VERTEX](../3.ngql-guide/12.vertex-statements/4.delete-vertex.md)、[INSERT EDGE](../3.ngql-guide/13.edge-statements/1.insert-edge.md)、[DELETE EDGE](../3.ngql-guide/13.edge-statements/4.delete-edge.md)。 不支持 openCypher 中的 MERGE 语句。 diff --git a/docs-2.0/1.introduction/3.nebula-graph-architecture/3.graph-service.md b/docs-2.0/1.introduction/3.nebula-graph-architecture/3.graph-service.md index eeb4187915d..fc901892b11 100644 --- a/docs-2.0/1.introduction/3.nebula-graph-architecture/3.graph-service.md +++ b/docs-2.0/1.introduction/3.nebula-graph-architecture/3.graph-service.md @@ -20,7 +20,7 @@ Graph 服务主要负责处理查询请求,包括解析查询语句、校验 Parser 模块收到请求后,通过 Flex(词法分析工具)和 Bison(语法分析工具)生成的词法语法解析器,将语句转换为抽象语法树(AST),在语法解析阶段会拦截不符合语法规则的语句。 -例如`GO FROM "Tim" OVER like WHERE like.likeness > 8.0 YIELD like._dst`语句转换的 AST 如下。 +例如`GO FROM "Tim" OVER like WHERE properties(edge).likeness > 8.0 YIELD dst(edge)`语句转换的 AST 如下。 ![AST](https://docs-cdn.nebula-graph.com.cn/docs-2.0/1.introduction/2.nebula-graph-architecture/parser-ast-tree.png) @@ -38,7 +38,7 @@ Validator 模块对生成的 AST 进行语义校验,主要包括: 校验引用的变量是否存在或者引用的属性是否属于变量。 - 例如语句`$var = GO FROM "Tim" OVER like YIELD like._dst AS ID; GO FROM $var.ID OVER serve YIELD serve._dst`,Validator 模块首先会检查变量 `var` 是否定义,其次再检查属性 `ID` 是否属于变量 `var`。 + 例如语句`$var = GO FROM "Tim" OVER like YIELD dst(edge) AS ID; GO FROM $var.ID OVER serve YIELD dst(edge)`,Validator 模块首先会检查变量 `var` 是否定义,其次再检查属性 `ID` 是否属于变量 `var`。 - 校验类型推断 @@ -50,13 +50,13 @@ Validator 模块对生成的 AST 进行语义校验,主要包括: 查询语句中包含 `*` 时,校验子句时需要将 `*` 涉及的Schema都进行校验。 - 例如语句`GO FROM "Tim" OVER * YIELD like._dst, like.likeness, serve._dst`,校验`OVER`子句时需要校验所有的 Edge type,如果 Edge type 包含 `like`和`serve`,该语句会展开为`GO FROM "Tim" OVER like,serve YIELD like._dst, like.likeness, serve._dst`。 + 例如语句`GO FROM "Tim" OVER * YIELD dst(edge), properties(edge).likeness, dst(edge)`,校验`OVER`子句时需要校验所有的 Edge type,如果 Edge type 包含 `like`和`serve`,该语句会展开为`GO FROM "Tim" OVER like,serve YIELD dst(edge), properties(edge).likeness, dst(edge)`。 - 校验输入输出 校验管道符(|)前后的一致性。 - 例如语句`GO FROM "Tim" OVER like YIELD like._dst AS ID | GO FROM $-.ID OVER serve YIELD serve._dst`,Validator 模块会校验 `$-.ID` 在管道符左侧是否已经定义。 + 例如语句`GO FROM "Tim" OVER like YIELD dst(edge) AS ID | GO FROM $-.ID OVER serve YIELD dst(edge)`,Validator 模块会校验 `$-.ID` 在管道符左侧是否已经定义。 校验完成后,Validator 模块还会生成一个默认可执行,但是未进行优化的执行计划,存储在目录 `src/planner` 内。 diff --git a/docs-2.0/1.introduction/3.nebula-graph-architecture/4.storage-service.md b/docs-2.0/1.introduction/3.nebula-graph-architecture/4.storage-service.md index c977a5cc277..b747dad8be1 100644 --- a/docs-2.0/1.introduction/3.nebula-graph-architecture/4.storage-service.md +++ b/docs-2.0/1.introduction/3.nebula-graph-architecture/4.storage-service.md @@ -142,6 +142,8 @@ EdgeA_Out和EdgeA_In以方向相反的两条边的形式存在于存储层,二 如EdgeA_Out和EdgeA_In一样,Nebula Graph冗余了存储每条边的信息,导致存储边所需的实际空间翻倍。因为边对应的Key占用的硬盘空间较小,但Value占用的空间与属性值的长度和数量成正比,所以,当边的属性值较大或数量较多时候,硬盘空间占用量会比较大。 +如果对边进行操作,为了保证两个键值对的最终一致性,可以开启[TOSS功能](../../5.configurations-and-logs/1.configurations/3.graph-config.md),开启后,会先在正向边所在的分片进行操作,然后在反向边所在分片进行操作,最后返回结果。 + ### 分片算法 分片策略采用**静态 Hash**的方式,即对点VID进行取模操作,同一个点的所有Tag、出边和入边信息都会存储到同一个分片,这种方式极大地提升了查询效率。 diff --git a/docs-2.0/1.introduction/3.vid.md b/docs-2.0/1.introduction/3.vid.md index d3a6c399d58..f53a71e1d06 100644 --- a/docs-2.0/1.introduction/3.vid.md +++ b/docs-2.0/1.introduction/3.vid.md @@ -28,7 +28,7 @@ - 可以使用`LOOKUP`或者`MATCH`语句,来通过属性索引查找对应的VID; -- 性能上,直接通过VID找到点的语句性能最高,例如`DELETE xxx WHERE id(xxx) == "player100"`, 或者`GO FROM "player100"`等语句。通过属性先查找VID,再进行图操作的性能会变差,例如`LOOKUP | GO FROM $-.ids`等语句,相比前者多了一次内存或硬盘的随机读(`LOOKUP`)以及一次序列化(`|`)。 +- 性能上,直接通过VID找到点的语句性能最高,例如`DELETE xxx WHERE id(xxx) == "player100"`,或者`GO FROM "player100"`等语句。通过属性先查找VID,再进行图操作的性能会变差,例如`LOOKUP | GO FROM $-.ids`等语句,相比前者多了一次内存或硬盘的随机读(`LOOKUP`)以及一次序列化(`|`)。 ## VID生成建议 @@ -50,13 +50,13 @@ VID的数据类型必须在[创建图空间](../3.ngql-guide/9.space-statements/ ## "查询起始点"(`start vid`)与全局扫描 -绝大多数情况下,Nebula Graph 的查询语句(`MATCH`, `GO`, `LOOKUP`)的执行计划,必须要通过一定方式找到查询起始点的 VID (`start vid`)。 +绝大多数情况下,Nebula Graph 的查询语句(`MATCH`、`GO`、`LOOKUP`)的执行计划,必须要通过一定方式找到查询起始点的 VID(`start vid`)。 定位 `start vid` 只有两种方式: 1. 例如 `GO FROM "player100" OVER` 是在语句中显式的指明 `start vid` 是 "player100"; -2. 例如, `LOOKUP ON player WHERE player.name == "Tony Parker"` 或者 `MATCH (v:player {name:"Tony Parker"}) `,是通过属性 `player.name` 的索引来定位到 `start vid`; +2. 例如 `LOOKUP ON player WHERE player.name == "Tony Parker"` 或者 `MATCH (v:player {name:"Tony Parker"}) `,是通过属性 `player.name` 的索引来定位到 `start vid`; !!! caution 不能在没有 `start vid` 情况下进行全局扫描; diff --git a/docs-2.0/14.client/4.nebula-java-client.md b/docs-2.0/14.client/4.nebula-java-client.md index 7ae1dcc909c..a68f665e8e3 100644 --- a/docs-2.0/14.client/4.nebula-java-client.md +++ b/docs-2.0/14.client/4.nebula-java-client.md @@ -101,7 +101,7 @@ try { ResultSet resp = session.execute(insertEdges); // query - String query = "GO FROM \"Bob\" OVER like " + "YIELD $$.person.name, $$.person.age, like.likeness"; + String query = "GO FROM \"Bob\" OVER like " + "YIELD properties($$).name, properties($$).age, properties(edge).likeness"; ResultSet resp = session.execute(query); printResult(resp); }finally { 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 ea78aab7b14..68346173c49 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 @@ -23,7 +23,7 @@ 本文将使用下图的数据集演示基础操作的语法。 -![The demo dataset](https://docs-cdn.nebula-graph.com.cn/docs-2.0/2.quick-start/dataset-for-crud.png) +![The demo dataset](dataset-for-crud.png) ## 检查Nebula Graph集群的机器状态 @@ -37,21 +37,17 @@ nebula> SHOW HOSTS; | Host | Port | Status | Leader count | Leader distribution | Partition distribution | +-------------+-----------+-----------+--------------+----------------------+------------------------+ | "storaged0" | 9779 | "ONLINE" | 0 | "No valid partition" | "No valid partition" | -+-------------+-----------+-----------+--------------+----------------------+------------------------+ | "storaged1" | 9779 | "ONLINE" | 0 | "No valid partition" | "No valid partition" | -+-------------+-----------+-----------+--------------+----------------------+------------------------+ | "storaged2" | 9779 | "ONLINE" | 0 | "No valid partition" | "No valid partition" | -+-------------+-----------+-----------+--------------+----------------------+------------------------+ | "Total" | __EMPTY__ | __EMPTY__ | 0 | __EMPTY__ | __EMPTY__ | +-------------+-----------+-----------+--------------+----------------------+------------------------+ -Got 4 rows (time spent 1061/2251 us) ``` 在返回结果中,查看**Status**列,可以看到所有Storage服务都在线。 ### 异步实现创建和修改 -!!! caution +!!! caution Nebula Graph中执行如下创建和修改操作,是异步实现的。要在**下一个**心跳周期之后才能生效;否则访问会报错。 @@ -81,7 +77,7 @@ Got 4 rows (time spent 1061/2251 us) ```ngql CREATE SPACE [IF NOT EXISTS] ( - [partition_num = ,] + [partition_num = ,] [replica_factor = ,] vid_type = {FIXED_STRING() | INT64} ) @@ -113,7 +109,6 @@ Got 4 rows (time spent 1061/2251 us) ```ngql nebula> CREATE SPACE basketballplayer(partition_num=15, replica_factor=1, vid_type=fixed_string(30)); - Execution succeeded (time spent 2817/3280 us) ``` 2. 执行命令`SHOW HOSTS`检查分片的分布情况,确保平衡分布。 @@ -124,14 +119,10 @@ Got 4 rows (time spent 1061/2251 us) | Host | Port | Status | Leader count | Leader distribution | Partition distribution | +-------------+-----------+-----------+--------------+----------------------------------+------------------------+ | "storaged0" | 9779 | "ONLINE" | 5 | "basketballplayer:5" | "basketballplayer:5" | - +-------------+-----------+-----------+--------------+----------------------------------+------------------------+ | "storaged1" | 9779 | "ONLINE" | 5 | "basketballplayer:5" | "basketballplayer:5" | - +-------------+-----------+-----------+--------------+----------------------------------+------------------------+ | "storaged2" | 9779 | "ONLINE" | 5 | "basketballplayer:5" | "basketballplayer:5" | - +-------------+-----------+-----------+--------------+----------------------------------+------------------------+ | "Total" | | | 15 | "basketballplayer:15" | "basketballplayer:15" | +-------------+-----------+-----------+--------------+----------------------------------+------------------------+ - Got 4 rows (time spent 1633/2867 us) ``` 如果**Leader distribution**分布不均匀,请执行命令`BALANCE LEADER`重新分配。更多信息,请参见[Storage负载均衡](../8.service-tuning/load-balance.md)。 @@ -140,7 +131,6 @@ Got 4 rows (time spent 1061/2251 us) ```ngql nebula[(none)]> USE basketballplayer; - Execution succeeded (time spent 1229/2318 us) ``` 用户可以执行命令`SHOW SPACES`查看创建的图空间。 @@ -152,7 +142,6 @@ Got 4 rows (time spent 1061/2251 us) +--------------------+ | "basketballplayer" | +--------------------+ - Got 1 rows (time spent 977/2000 us) ``` ## 创建Tag和Edge type @@ -180,16 +169,12 @@ CREATE {TAG | EDGE} { | }( ```ngql nebula> CREATE TAG player(name string, age int); -Execution succeeded (time spent 20708/22071 us) nebula> CREATE TAG team(name string); -Execution succeeded (time spent 5643/6810 us) nebula> CREATE EDGE follow(degree int); -Execution succeeded (time spent 12665/13934 us) nebula> CREATE EDGE serve(start_year int, end_year int); -Execution succeeded (time spent 5858/6870 us) ``` ## 插入点和边 @@ -225,32 +210,24 @@ Execution succeeded (time spent 5858/6870 us) ```ngql nebula> INSERT VERTEX player(name, age) VALUES "player100":("Tim Duncan", 42); - Execution succeeded (time spent 28196/30896 us) nebula> INSERT VERTEX player(name, age) VALUES "player101":("Tony Parker", 36); - Execution succeeded (time spent 2708/3834 us) nebula> INSERT VERTEX player(name, age) VALUES "player102":("LaMarcus Aldridge", 33); - Execution succeeded (time spent 1945/3294 us) - nebula> INSERT VERTEX team(name) VALUES "team200":("Warriors"), "team201":("Nuggets"); - Execution succeeded (time spent 2269/3310 us) + nebula> INSERT VERTEX team(name) VALUES "team203":("Trail Blazers"), "team204":("Spurs"); ``` - 插入代表球员和球队之间关系的边。 ```ngql - nebula> INSERT EDGE follow(degree) VALUES "player100" -> "player101":(95); - Execution succeeded (time spent 3362/4542 us) + nebula> INSERT EDGE follow(degree) VALUES "player101" -> "player100":(95); - nebula> INSERT EDGE follow(degree) VALUES "player100" -> "player102":(90); - Execution succeeded (time spent 2974/4274 us) + nebula> INSERT EDGE follow(degree) VALUES "player101" -> "player102":(90); - nebula> INSERT EDGE follow(degree) VALUES "player102" -> "player101":(75); - Execution succeeded (time spent 1891/3096 us) + nebula> INSERT EDGE follow(degree) VALUES "player102" -> "player100":(75); - nebula> INSERT EDGE serve(start_year, end_year) VALUES "player100" -> "team200":(1997, 2016), "player101" -> "team201":(1999, 2018); - Execution succeeded (time spent 6064/7104 us) + nebula> INSERT EDGE serve(start_year, end_year) VALUES "player101" -> "team204":(1999, 2018),"player102" -> "team203":(2006, 2015); ``` ## 查询数据 @@ -269,9 +246,13 @@ Execution succeeded (time spent 5858/6870 us) ```ngql GO [[ TO] STEPS ] FROM - OVER [REVERSELY] [BIDIRECT] - [WHERE [AND | OR expression ...])] - YIELD [DISTINCT] ; + OVER [{REVERSELY | BIDIRECT}] + [ WHERE  ] + [YIELD [DISTINCT] ] + [{SAMPLE | LIMIT }] + [| GROUP BY {col_name | expr | position} YIELD ] + [| ORDER BY [{ASC | DESC}]] + [| LIMIT [,] ]; ``` - `FETCH` @@ -279,24 +260,24 @@ Execution succeeded (time spent 5858/6870 us) - 查询Tag属性 ```ngql - FETCH PROP ON { | | *} - [YIELD [DISTINCT] ]; + FETCH PROP ON {[, tag_name ...] | *} + [, vid ...] + [YIELD [AS ]]; ``` - 查询边属性 ```ngql - FETCH PROP ON -> [@] - [, -> ...] - [YIELD [DISTINCT] ]; + FETCH PROP ON -> [@] [, -> ...] + [YIELD ]; ``` - `LOOKUP` ```ngql - LOOKUP ON { | } - WHERE [AND expression ...])] - [YIELD ]; + LOOKUP ON { | } + [WHERE [AND ...]] + [YIELD [AS ]]; ``` - `MATCH` @@ -307,31 +288,28 @@ Execution succeeded (time spent 5858/6870 us) ### `GO`语句示例 -- 从VID为`player100`的球员开始,沿着边`follow`找到连接的球员。 +- 从VID为`player101`的球员开始,沿着边`follow`找到连接的球员。 ```ngql - nebula> GO FROM "player100" OVER follow; + nebula> GO FROM "player101" OVER follow; +-------------+ | follow._dst | +-------------+ - | "player101" | - +-------------+ + | "player100" | | "player102" | +-------------+ - Got 2 rows (time spent 12097/14220 us) ``` -- 从VID为`player100`的球员开始,沿着边`follow`查找年龄大于或等于35岁的球员,并返回他们的姓名和年龄,同时重命名对应的列。 +- 从VID为`player101`的球员开始,沿着边`follow`查找年龄大于或等于35岁的球员,并返回他们的姓名和年龄,同时重命名对应的列。 ```ngql - nebula> GO FROM "player100" OVER follow WHERE $$.player.age >= 35 \ - YIELD $$.player.name AS Teammate, $$.player.age AS Age; - +---------------+-----+ - | Teammate | Age | - +---------------+-----+ - | "Tony Parker" | 36 | - +---------------+-----+ - Got 1 rows (time spent 8206/9335 us) + nebula> GO FROM "player101" OVER follow WHERE properties($$).age >= 35 \ + YIELD properties($$).name AS Teammate, properties($$).age AS Age; + +--------------+-----+ + | Teammate | Age | + +--------------+-----+ + | "Tim Duncan" | 42 | + +--------------+-----+ ``` |子句/符号|说明| @@ -340,22 +318,21 @@ Execution succeeded (time spent 5858/6870 us) |`$$`|表示边的终点。| |`\`|表示换行继续输入。| -- 从VID为`player100`的球员开始,沿着边`follow`查找连接的球员,然后检索这些球员的球队。为了合并这两个查询请求,可以使用管道符或临时变量。 +- 从VID为`player101`的球员开始,沿着边`follow`查找连接的球员,然后检索这些球员的球队。为了合并这两个查询请求,可以使用管道符或临时变量。 - 使用管道符 ```ngql - nebula> GO FROM "player100" OVER follow YIELD follow._dst AS id | \ - GO FROM $-.id OVER serve YIELD $$.team.name AS Team, \ - $^.player.name AS Player; - +-----------+---------------+ - | Team | Player | - +-----------+---------------+ - | "Nuggets" | "Tony Parker" | - +-----------+---------------+ - Got 1 rows (time spent 5055/8203 us) - ``` - + nebula> GO FROM "player101" OVER follow YIELD dst(edge) AS id | \ + GO FROM $-.id OVER serve YIELD properties($$).name AS Team, \ + properties($^).name AS Player; + +-----------------+---------------------+ + | Team | Player | + +-----------------+---------------------+ + | "Trail Blazers" | "LaMarcus Aldridge" | + +-----------------+---------------------+ + ``` + |子句/符号|说明| |:---|:---| | `$^` |表示边的起点。| @@ -369,15 +346,14 @@ Execution succeeded (time spent 5858/6870 us) 当复合语句作为一个整体提交给服务器时,其中的临时变量会在语句结束时被释放。 ```ngql - nebula> $var = GO FROM "player100" OVER follow YIELD follow._dst AS id; \ - GO FROM $var.id OVER serve YIELD $$.team.name AS Team, \ - $^.player.name AS Player; - +---------+-------------+ - | Team | Player | - +---------+-------------+ - | Nuggets | Tony Parker | - +---------+-------------+ - Got 1 rows (time spent 3103/3711 us) + nebula> $var = GO FROM "player101" OVER follow YIELD dst(edge) AS id; \ + GO FROM $var.id OVER serve YIELD properties($$).name AS Team, \ + properties($^).name AS Player; + +-----------------+---------------------+ + | Team | Player | + +-----------------+---------------------+ + | "Trail Blazers" | "LaMarcus Aldridge" | + +-----------------+---------------------+ ``` ### `FETCH`语句示例 @@ -391,7 +367,6 @@ nebula> FETCH PROP ON player "player100"; +----------------------------------------------------+ | ("player100" :player{age: 42, name: "Tim Duncan"}) | +----------------------------------------------------+ -Got 1 rows (time spent 2006/2406 us) ``` !!! Note @@ -437,7 +412,6 @@ Got 1 rows (time spent 2006/2406 us) ```ngql nebula> UPDATE VERTEX "player100" SET player.name = "Tim"; - Execution succeeded (time spent 3483/3914 us) nebula> FETCH PROP ON player "player100"; +---------------------------------------------+ @@ -445,41 +419,34 @@ Got 1 rows (time spent 2006/2406 us) +---------------------------------------------+ | ("player100" :player{age: 42, name: "Tim"}) | +---------------------------------------------+ - Got 1 rows (time spent 2463/3042 us) ``` - 用`UPDATE`修改某条边的`degree`属性,然后用`FETCH`检查结果。 ```ngql - nebula> UPDATE EDGE "player100" -> "player101" OF follow SET degree = 96; - Execution succeeded (time spent 3932/4432 us) + nebula> UPDATE EDGE "player101" -> "player100" OF follow SET degree = 96; - nebula> FETCH PROP ON follow "player100" -> "player101"; + nebula> FETCH PROP ON follow "player101" -> "player100"; +----------------------------------------------------+ | edges_ | +----------------------------------------------------+ - | [:follow "player100"->"player101" @0 {degree: 96}] | + | [:follow "player101"->"player100" @0 {degree: 96}] | +----------------------------------------------------+ - Got 1 rows (time spent 2205/2800 us) ``` -- 用`UPSERT`插入一个VID为`player111`的点。 +- 用`INSERT`插入一个VID为`player111`的点,然后用`UPSERT`更新它。 ```ngql - nebula> INSERT VERTEX player(name, age) VALUES "player111":("Ben Simmons", 22); - Execution succeeded (time spent 2115/2900 us) + nebula> INSERT VERTEX player(name,age) values "player111":("David West", 38); - Wed, 21 Oct 2020 11:11:50 UTC - - nebula> UPSERT VERTEX "player111" SET player.name = "Dwight Howard", player.age = $^.player.age + 11 \ - WHEN $^.player.name == "Ben Simmons" AND $^.player.age > 20 \ + nebula> UPSERT VERTEX "player111" SET player.name = "David", player.age = $^.player.age + 11 \ + WHEN $^.player.name == "David West" AND $^.player.age > 20 \ YIELD $^.player.name AS Name, $^.player.age AS Age; - +---------------+-----+ - | Name | Age | - +---------------+-----+ - | Dwight Howard | 33 | - +---------------+-----+ - Got 1 rows (time spent 1815/2329 us) + +---------+-----+ + | Name | Age | + +---------+-----+ + | "David" | 49 | + +---------+-----+ ``` ## 删除点和边 @@ -504,15 +471,13 @@ Got 1 rows (time spent 2006/2406 us) - 删除点 ```ngql - nebula> DELETE VERTEX "team1", "team2"; - Execution succeeded (time spent 4337/4782 us) + nebula> DELETE VERTEX "player111", "team203"; ``` - 删除边 ```ngql - nebula> DELETE EDGE follow "team1" -> "team2"; - Execution succeeded (time spent 3700/4101 us) + nebula> DELETE EDGE follow "player101" -> "team204"; ``` ## 索引 @@ -530,7 +495,7 @@ Got 1 rows (time spent 2006/2406 us) - 创建索引 ```ngql - CREATE {TAG | EDGE} INDEX [IF NOT EXISTS] + CREATE {TAG | EDGE} INDEX [IF NOT EXISTS] ON { | } ([]) [COMMENT = '']; ``` @@ -540,17 +505,8 @@ Got 1 rows (time spent 2006/2406 us) REBUILD {TAG | EDGE} INDEX ; ``` -### 示例 - -为Tag`player`的属性`name`创建索引,并且重建索引。 - -```ngql -nebula> CREATE TAG INDEX player_index_0 on player(name(20)); -nebula> REBUILD TAG INDEX player_index_0; -``` - !!! Note - + 为没有指定长度的变量属性创建索引时,需要指定索引长度。在utf-8编码中,一个中文字符占3字节,请根据变量属性长度设置合适的索引长度。例如10个中文字符,索引长度需要为30。详情请参见[创建索引](../3.ngql-guide/14.native-index-statements/1.create-native-index.md#_6)。 ### 基于索引的`LOOKUP`和`MATCH`示例 @@ -560,27 +516,25 @@ nebula> REBUILD TAG INDEX player_index_0; 找到Tag为`player`的点的信息,它的`name`属性值为`Tony Parker`。 ```nGQL -// 为name属性创建索引player_name_0。 -nebula> CREATE TAG INDEX player_name_0 on player(name(10)); -Execution succeeded (time spent 3465/4150 us) +// 为name属性创建索引player_index_1。 +nebula> CREATE TAG INDEX player_index_1 ON player(name(20)); // 重建索引确保能对已存在数据生效。 -nebula> REBUILD TAG INDEX player_name_0 +nebula> REBUILD TAG INDEX player_index_1 +------------+ | New Job Id | +------------+ | 31 | +------------+ -Got 1 rows (time spent 2379/3033 us) // 使用LOOKUP语句检索点的属性。 nebula> LOOKUP ON player WHERE player.name == "Tony Parker" \ - YIELD player.name, player.age; -+-------------+---------------+------------+ -| VertexID | player.name | player.age | -+-------------+---------------+------------+ -| "player101" | "Tony Parker" | 36 | -+-------------+---------------+------------+ + YIELD properties(vertex).name AS name, properties(vertex).age AS age; ++-------------+---------------+-----+ +| VertexID | name | age | ++-------------+---------------+-----+ +| "player101" | "Tony Parker" | 36 | ++-------------+---------------+-----+ // 使用MATCH语句检索点的属性。 nebula> MATCH (v:player{name:"Tony Parker"}) RETURN v; @@ -589,5 +543,4 @@ nebula> MATCH (v:player{name:"Tony Parker"}) RETURN v; +-----------------------------------------------------+ | ("player101" :player{age: 36, name: "Tony Parker"}) | +-----------------------------------------------------+ -Got 1 rows (time spent 5132/6246 us) ``` diff --git a/docs-2.0/2.quick-start/6.cheatsheet-for-ngql-command.md b/docs-2.0/2.quick-start/6.cheatsheet-for-ngql-command.md new file mode 100644 index 00000000000..919b0851e8d --- /dev/null +++ b/docs-2.0/2.quick-start/6.cheatsheet-for-ngql-command.md @@ -0,0 +1,513 @@ +# nGQL命令汇总 + +## 函数 + +- [数学函数](../3.ngql-guide/6.functions-and-expressions/1.math.md) + + | 函数 | 说明 | + | :-------------------------------------- | :----------------------------------------------------------- | + | double abs(double x) | 返回x的绝对值。 | + | double floor(double x) | 返回小于或等于x的最大整数。 | + | double ceil(double x) | 返回大于或等于x的最小整数。 | + | double round(double x) | 返回离x最近的整数值,如果x恰好在中间,则返回离0较远的整数。 | + | double sqrt(double x) | 返回x的平方根。 | + | double cbrt(double x) | 返回x的立方根。 | + | double hypot(double x, double y) | 返回直角三角形(直角边长为x和y)的斜边长。 | + | double pow(double x, double y) | 返回$x^y$的值。 | + | double exp(double x) | 返回$e^x$的值。 | + | double exp2(double x) | 返回$2^x2$的值。 | + | double log(double x) | 返回以自然数e为底x的对数。 | + | double log2(double x) | 返回以2为底x的对数。 | + | double log10(double x) | 返回以10为底x的对数。 | + | double sin(double x) | 返回x的正弦值。 | + | double asin(double x) | 返回x的反正弦值。 | + | double cos(double x) | 返回x的余弦值。 | + | double acos(double x) | 返回x的反余弦值。 | + | double tan(double x) | 返回x的正切值。 | + | double atan(double x) | 返回x的反正切值。 | + | double rand() | 返回[0,1)内的随机浮点数。 | + | int rand32(int min, int max) | 返回`[min, max)`内的一个随机32位整数。 用户可以只传入一个参数,该参数会判定为`max`,此时`min`默认为`0`。 如果不传入参数,此时会从带符号的32位int范围内随机返回。 | + | int rand64(int min, int max) | 返回`[min, max)`内的一个随机64位整数。 用户可以只传入一个参数,该参数会判定为`max`,此时`min`默认为`0`。 如果不传入参数,此时会从带符号的64位int范围内随机返回。 | + | collect() | 将收集的所有值放在一个列表中。 | + | avg() | 返回参数的平均值。 | + | count() | 返回参数的数量。 | + | max() | 返回参数的最大值。 | + | min() | 返回参数的最小值。 | + | std() | 返回参数的总体标准差。 | + | sum() | 返回参数的和。 | + | bit_and() | 逐位做AND操作。 | + | bit_or() | 逐位做OR操作。 | + | bit_xor() | 逐位做XOR操作。 | + | int size() | 返回列表或映射中元素的数量。 | + | int range(int start, int end, int step) | 返回`[start,end]`中指定步长的值组成的列表。步长`step`默认为1。 | + | int sign(double x) | 返回x的正负号。 如果x为`0`,则返回`0`。 如果x为负数,则返回`-1`。 如果x为正数,则返回`1`。 | + | double e() | 返回自然对数的底e(2.718281828459045)。 | + | double pi() | 返回数学常数π(3.141592653589793)。 | + | double radians() | 将角度转换为弧度。`radians(180)`返回`3.141592653589793`。 | + + + +- [字符串函数](../3.ngql-guide/6.functions-and-expressions/2.string.md) + + | 函数 | 说明 | + | :---------------------------------------------- | :----------------------------------------------------------- | + | int strcasecmp(string a, string b) | 比较两个字符串(不区分大小写)。当a=b时,返回0,当a>b是,返回大于0的数,当a`count()`返回总行数(包括NULL)。
`count(expr)`返回满足表达式的非空值的总数。
`count()`和`size()`是不同的。 | + + + +* [collect函数](../3.ngql-guide/6.functions-and-expressions/10.collect.md) + + | 函数 | 说明 | + | :-------- | :----------------------------------------------------------- | + | collect() | `collect()`函数返回一个符合表达式返回结果的列表。该函数可以将多条记录或值合并进一个列表,实现数据聚合。 | + + + +* [reduce函数](../3.ngql-guide/6.functions-and-expressions/11.reduce.md) + + | 函数 | 语法 | 说明 | + | :------- | :-------------------------------------------------------- | ------------------------------------------------------------ | + | reduce() | `reduce( = , IN ` | `reduce()`将表达式逐个应用于列表中的元素,然后和累加器中的当前结果累加,最后返回完整结果。 | + + + +* [hash函数](../3.ngql-guide/6.functions-and-expressions/12.hash.md) + + | 函数 | 说明 | + | :----- | :----------------------------------------------------------- | + | hash() | `hash()`函数返回参数的哈希值。其参数可以是数字、字符串、列表、布尔值、NULL等类型的值,或者计算结果为这些类型的表达式。`hash()`函数采用MurmurHash2算法,种子(seed)为`0xc70f6907UL`。用户可以在[`MurmurHash2.h`](https://github.com/vesoft-inc/nebula/blob/master/src/common/base/MurmurHash2.h)中查看其源代码。 | + + + +* [concat函数](../3.ngql-guide/6.functions-and-expressions/13.concat.md) + + | 函数 | 说明 | + | :------- | :----------------------------------------------------------- | + | concat() | `concat()`函数至少需要两个或以上字符串参数,并将所有参数连接成一个字符串。
语法:`concat(string1,string2,...)` | + + + +* [concat_ws函数](../3.ngql-guide/6.functions-and-expressions/13.concat.md) + + | 函数 | 说明 | + | ----------- | ------------------------------------------------------------ | + | concat_ws() | `concat_ws()`函数将两个或以上字符串参数与预定义的分隔符(separator)相连接。 | + + + +* [谓词函数](../3.ngql-guide/6.functions-and-expressions/8.predicate.md) + + 谓词函数只返回`true`或`false`,通常用于`WHERE`子句中。 + + ``` + ( IN WHERE ) + ``` + + | 函数 | 说明 | + | :------- | :----------------------------------------------------------- | + | exists() | 如果指定的属性在点、边或映射中存在,则返回`true`,否则返回`false`。 | + | any() | 如果指定的谓词适用于列表中的至少一个元素,则返回`true`,否则返回`false`。 | + | all() | 如果指定的谓词适用于列表中的每个元素,则返回`true`,否则返回`false`。 | + | none() | 如果指定的谓词不适用于列表中的任何一个元素,则返回`true`,否则返回`false`。 | + | single() | 如果指定的谓词适用于列表中的唯一一个元素,则返回`true`,否则返回`false`。 | + + + +* [CASE表达式](../3.ngql-guide/6.functions-and-expressions/5.case-expressions.md) + + `CASE`表达式使用条件来过滤nGQL查询语句的结果,常用于`YIELD`和`RETURN`子句中。`CASE`表达式会遍历所有条件,并在满足第一个条件时停止读取后续条件,然后返回结果。如果不满足任何条件,将通过`ELSE`子句返回结果。如果没有`ELSE`子句且不满足任何条件,则返回`NULL`。 + + 语法: + + ``` + CASE + WHEN THEN + [WHEN ...] + [ELSE ] + END + ``` + + | 参数 | 说明 | + | :--------- | :--------------------------------------------- | + | `comparer` | 用于与`value`进行比较的值或者有效表达式。 | + | `value` | 和`comparer`进行比较,如果匹配,则满足此条件。 | + | `result` | 如果`value`匹配`comparer`,则返回该`result`。 | + | `default` | 如果没有条件匹配,则返回该`default`。 | + + + +## 通用查询语句 + +* [MATCH](../3.ngql-guide/7.general-query-statements/2.match.md) + + ``` + MATCH [] RETURN + ``` + + | 模式 | 示例 | 说明 | + | --------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | + | 匹配点 | `(v)` | 用户可以在一对括号中使用自定义变量来表示模式中的点。例如`(v)`。 | + | 匹配Tag | `MATCH (v:player) RETURN v` | 用户可以在点的右侧用`:`表示模式中的Tag。 | + | 匹配点的属性 | `MATCH (v:player{name:"Tim Duncan"}) RETURN v` | 用户可以在Tag的右侧用`{: }`表示模式中点的属性。 | + | 匹配单点ID | `MATCH (v) WHERE id(v) == 'player101' RETURN v` | 用户可以使用点ID去匹配点。`id()`函数可以检索点的ID。 | + | 匹配多点ID | `MATCH (v:player { name: 'Tim Duncan' })--(v2) WHERE id(v2) IN ["player101", "player102"] RETURN v2` | 要匹配多个点的ID,可以用`WHERE id(v) IN [vid_list]`。 | + | 匹配连接的点 | `MATCH (v:player{name:"Tim Duncan"})--(v2) RETURN v2.name AS Name` | 用户可以使用`--`符号表示两个方向的边,并匹配这些边连接的点。用户可以在`--`符号上增加`<`或`>`符号指定边的方向。 | + | 匹配路径 | `MATCH p=(v:player{name:"Tim Duncan"})-->(v2) RETURN p` | 连接起来的点和边构成了路径。用户可以使用自定义变量命名路径。 | + | 匹配边 | `MATCH (v:player{name:"Tim Duncan"})-[e]-(v2) RETURN e` | 除了用`--`、`-->`、`<--`表示未命名的边之外,用户还可以在方括号中使用自定义变量命名边。例如`-[e]-`。 | + | 匹配Edge type | `MATCH ()-[e:follow]-() RETURN e` | 和点一样,用户可以用`:`表示模式中的Edge type,例如`-[e:follow]-`。 | + | 匹配边的属性 | ` MATCH (v:player{name:"Tim Duncan"})-[e:follow{degree:95}]->(v2) RETURN e` | 用户可以用`{: }`表示模式中Edge type的属性,例如`[e:follow{likeness:95}]`。 | + | 匹配多个Edge type | `MATCH (v:player{name:"Tim Duncan"})-[e:follow \| :serve]->(v2) RETURN e` | 使用`\|`可以匹配多个Edge type,例如`[e:follow \| :serve]`。第一个Edge type前的英文冒号(:)不可省略,后续Edge type前的英文冒号可以省略,例如`[e:follow \| serve]`。 | + | 匹配多条边 | `MATCH (v:player{name:"Tim Duncan"})-[]->(v2)<-[e:serve]-(v3) RETURN v2, v3` | 用户可以扩展模式,匹配路径中的多条边。 | + | 匹配定长路径 | `MATCH p=(v:player{name:"Tim Duncan"})-[e:follow*2]->(v2) RETURN DISTINCT v2 AS Friends` | 用户可以在模式中使用`:*`匹配定长路径。`hop`必须是一个非负整数。 | + | 匹配变长路径 | `MATCH p=(v:player{name:"Tim Duncan"})-[e:follow*1..3]->(v2) RETURN v2 AS Friends` | `minHop`:可选项。表示路径的最小长度。`minHop`必须是一个非负整数,默认值为1。
`maxHop`:必选项。表示路径的最大长度。`maxHop`必须是一个非负整数,没有默认值。 | + | 匹配多个Edge type的变长路径 | `MATCH p=(v:player{name:"Tim Duncan"})-[e:follow \| serve*2]->(v2) RETURN DISTINCT v2` | 用户可以在变长或定长模式中指定多个Edge type。`hop`、`minHop`和`maxHop`对所有Edge type都生效。 | + | 检索点或边的信息 | `MATCH (v:player{name:"Tim Duncan"}) RETURN v`
`MATCH (v:player{name:"Tim Duncan"})-[e]->(v2) RETURN e` | 使用`RETURN { \| }`检索点或边的所有信息。 | + | 检索点ID | `MATCH (v:player{name:"Tim Duncan"}) RETURN id(v)` | 使用`id()`函数检索点ID。 | + | 检索Tag | `MATCH (v:player{name:"Tim Duncan"}) RETURN labels(v)` | 使用`labels()`函数检索点上的Tag列表。
检索列表`labels(v)`中的第N个元素,可以使用`labels(v)[n-1]`。 | + | 检索点或边的单个属性 | `MATCH (v:player{name:"Tim Duncan"}) RETURN v.age` | 使用`RETURN { \| }.`检索单个属性。
使用`AS`设置属性的别名。 | + | 检索点或边的所有属性 | `MATCH p=(v:player{name:"Tim Duncan"})-[]->(v2) RETURN properties(v2)` | 使用`properties()`函数检索点或边的所有属性。 | + | 检索Edge type | `MATCH p=(v:player{name:"Tim Duncan"})-[e]->() RETURN DISTINCT type(e)` | 使用`type()`函数检索匹配的Edge type。 | + | 检索路径 | `MATCH p=(v:player{name:"Tim Duncan"})-[*3]->() RETURN p` | 使用`RETURN `检索匹配路径的所有信息。 | + | 检索路径中的点 | `MATCH p=(v:player{name:"Tim Duncan"})-[]->(v2) RETURN nodes(p)` | 使用`nodes()`函数检索路径中的所有点。 | + | 检索路径中的边 | `MATCH p=(v:player{name:"Tim Duncan"})-[]->(v2) RETURN relationships(p)` | 使用`relationships()`函数检索路径中的所有边。 | + | 检索路径长度 | `MATCH p=(v:player{name:"Tim Duncan">})-[*..2]->(v2) RETURN p AS Paths, length(p) AS Length` | 使用`length()`函数检索路径的长度。 | + + + +* [LOOKUP](../3.ngql-guide/7.general-query-statements/5.lookup.md) + + ``` + LOOKUP ON { | } + [WHERE [AND ...]] + [YIELD [AS ]] + ``` + + | 模式 | 示例 | 说明 | + | ------------------- | ------------------------------------------------------------ | ---------------------------------------------- | + | 检索点 | `LOOKUP ON player WHERE player.name == "Tony Parker" YIELD player.name AS name, player.age AS age` | 返回Tag为`player`且`name`为`Tony Parker`的点。 | + | 检索边 | `LOOKUP ON follow WHERE follow.degree == 90 YIELD follow.degree` | 返回Edge type为`follow`且`degree`为`90`的边。 | + | 通过Tag列出所有点 | `LOOKUP ON player` | 查找所有Tag为`player`的点 VID。 | + | 通过Edge type列出边 | `LOOKUP ON like` | 查找Edge type为`like`的所有边的信息。 | + | 统计点 | `LOOKUP ON player \| YIELD COUNT(*) AS Player_Number` | 统计Tag为`player`的点。 | + | 统计边 | `LOOKUP ON like \| YIELD COUNT(*) AS Like_Number` | 统计Edge type为`like`的边。 | + + + +* [GO](../3.ngql-guide/7.general-query-statements/3.go.md) + + ``` + GO [[ TO] STEPS ] FROM + OVER [{REVERSELY | BIDIRECT}] + [ WHERE ] + [YIELD [DISTINCT] ] + [| GROUP BY {col_name | expr | position} YIELD ] + [| ORDER BY [{ASC | DESC}]] + [| LIMIT [,] ] + ``` + + | 示例 | 说明 | + | ------------------------------------------------------------ | ------------------------------------------------------- | + | `GO FROM "player102" OVER serve` | 返回player102所属队伍。 | + | `GO 2 STEPS FROM "player102" OVER follow` | 返回距离player102两跳的朋友。 | + | `GO FROM "player100", "player102" OVER serve WHERE properties(edge).start_year > 1995 YIELD DISTINCT properties($$).name AS team_name, properties(edge).start_year AS start_year, properties($^).name AS player_name` | 添加过滤条件。 | + | `GO FROM "player100" OVER follow, serve YIELD properties(edge).degree, properties(edge).start_year` | 遍历多个Edge type。属性没有值时,会显示`UNKNOWN_PROP`。 | + | `GO FROM "player100" OVER follow REVERSELY YIELD src(edge) AS destination` | 返回player100入方向的邻居点。 | + | `GO FROM "player100" OVER follow REVERSELY YIELD src(edge) AS id \| GO FROM $-.id OVER serve WHERE properties($^).age > 20 YIELD properties($^).name AS FriendOf, properties($$).name AS Team` | 查询player100的朋友和朋友所属队伍。 | + | `GO FROM "player102" OVER follow YIELD dst(edge) AS both` | 返回player102所有邻居点。 | + | `GO 2 STEPS FROM "player100" OVER follow YIELD src(edge) AS src, dst(edge) AS dst, properties($$).age AS age \| GROUP BY $-.dst YIELD $-.dst AS dst, collect_set($-.src) AS src, collect($-.age) AS age` | 根据年龄分组。 | + + + +* [FETCH](../3.ngql-guide/7.general-query-statements/4.fetch.md) + + ``` + FETCH PROP ON {[, tag_name ...] | *} + [, vid ...] + [YIELD [AS ]] + ``` + + | 示例 | 说明 | + | ------------------------------------------------------------ | ------------------------------------------------------------ | + | `FETCH PROP ON player "player100"` | 在`FETCH`语句中指定Tag获取对应点的属性值。 | + | `FETCH PROP ON player "player100" YIELD player.name AS name` | 使用`YIELD`子句指定返回的属性。 | + | `FETCH PROP ON player "player101", "player102", "player103"` | 指定多个点ID获取多个点的属性值,点之间用英文逗号(,)分隔。 | + | `FETCH PROP ON player, t1 "player100", "player103"` | 在`FETCH`语句中指定多个Tag获取属性值。Tag之间用英文逗号(,)分隔。 | + | `FETCH PROP ON * "player100", "player106", "team200"` | 在`FETCH`语句中使用`*`获取当前图空间所有标签里,点的属性值。 | + | `FETCH PROP ON serve "player102" -> "player106" YIELD dst(edge)` | 语法:`FETCH PROP ON -> [@] [, -> ...] [YIELD ]` | + | `FETCH PROP ON serve "player100" -> "team204"` | 获取连接player100和team204的边serve的所有属性值。 | + | `FETCH PROP ON serve "player100" -> "team204" YIELD serve.start_year` | 使用`YIELD`子句指定返回的属性。 | + | `FETCH PROP ON serve "player100" -> "team204", "player133" -> "team202"` | 指定多个边模式(` -> [@]`)获取多个边的属性值。模式之间用英文逗号(,)分隔。 | + | `FETCH PROP ON serve "player100" -> "team204"@1` | 要获取rank不为0的边,请在FETCH语句中设置rank。 | + | `GO FROM "player101" OVER follow YIELD follow._src AS s, follow._dst AS d \| FETCH PROP ON follow $-.s -> $-.d YIELD follow.degree` | 返回从点player101开始的follow边的degree值。 | + | `$var = GO FROM "player101" OVER follow YIELD follow._src AS s, follow._dst AS d; FETCH PROP ON follow $var.s -> $var.d YIELD follow.degree` | 自定义变量构建查询。 | + + + +* [UNWIND](../3.ngql-guide/7.general-query-statements/7.unwind.md) + + ``` + UNWIND AS + ``` + + | 示例 | 说明 | + | ------------------------------------------------------------ | ------------------------------------------------------------ | + | `UNWIND [1,2,3] AS n RETURN n` | 拆分列表。 | + | `WITH [1,1,2,2,3,3] AS n UNWIND n AS r WITH DISTINCT r AS r ORDER BY r RETURN collect(r)` | 1. 拆分列表`[1,1,2,2,3,3]`。 2. 删除重复行。 3. 排序行。 4. 将行转换为列表。 | + | `MATCH p=(v:player{name:"Tim Duncan"})--(v2) WITH nodes(p) AS n UNWIND n AS r WITH DISTINCT r AS r RETURN collect(r)` | 1. 将匹配路径上的顶点输出到列表中。 2. 拆分列表。 3. 删除重复行。 4. 将行转换为列表。 | + + + +* SHOW + + | 语句 | 语法 | 示例 | 说明 | + | ------------------------------------------------------------ | ------------------------------------------------- | ------------------------------------ | -------------------------------------------------------- | + | [SHOW CHARSET](../3.ngql-guide/7.general-query-statements/6.show/1.show-charset.md) | `SHOW CHARSET` | `SHOW CHARSET` | 显示当前的字符集。 | + | [SHOW COLLATION](../3.ngql-guide/7.general-query-statements/6.show/2.show-collation.md) | `SHOW COLLATION` | `SHOW COLLATION` | 显示当前的排序规则。 | + | [SHOW CREATE SPACE](../3.ngql-guide/7.general-query-statements/6.show/4.show-create-space.md) | `SHOW CREATE SPACE ` | `SHOW CREATE SPACE basketballplayer` | 显示指定图空间的创建语句。 | + | [SHOW CREATE TAG/EDGE](../3.ngql-guide/7.general-query-statements/6.show/5.show-create-tags-edges.md) | `SHOW CREATE {TAG \| EDGE }` | `SHOW CREATE TAG player` | 显示指定Tag/Edge type的基本信息。 | + | [SHOW HOSTS](../3.ngql-guide/7.general-query-statements/6.show/6.show-hosts.md) | `SHOW HOSTS [GRAPH \| STORAGE \| META]` | `SHOW HOSTS`
`SHOW HOSTS GRAPH` | 显示Graph、Storage、Meta服务主机信息、版本信息。 | + | [SHOW INDEX STATUS](../3.ngql-guide/7.general-query-statements/6.show/7.show-index-status.md) | `SHOW {TAG \| EDGE} INDEX STATUS` | `SHOW TAG INDEX STATUS` | 重建原生索引的作业状态,以便确定重建索引是否成功。 | + | [SHOW INDEXES](../3.ngql-guide/7.general-query-statements/6.show/8.show-indexes.md) | `SHOW {TAG \| EDGE} INDEXES` | `SHOW TAG INDEXES` | 列出当前图空间内的所有Tag和Edge type(包括属性)的索引。 | + | [SHOW PARTS](../3.ngql-guide/7.general-query-statements/6.show/9.show-parts.md) | `SHOW PARTS []` | `SHOW PARTS` | 显示图空间中指定分片或所有分片的信息。 | + | [SHOW ROLES](../3.ngql-guide/7.general-query-statements/6.show/10.show-roles.md) | `SHOW ROLES IN ` | `SHOW ROLES in basketballplayer` | 显示分配给用户的角色信息。 | + | [SHOW SNAPSHOTS](../3.ngql-guide/7.general-query-statements/6.show/11.show-snapshots.md) | `SHOW SNAPSHOTS` | `SHOW SNAPSHOTS` | 显示所有快照信息。 | + | [SHOW SPACES](../3.ngql-guide/7.general-query-statements/6.show/12.show-spaces.md) | `SHOW SPACES` | `SHOW SPACES` | 显示现存的图空间。 | + | [SHOW STATS](../3.ngql-guide/7.general-query-statements/6.show/14.show-stats.md) | `SHOW STATS` | `SHOW STATS` | 显示最近`STATS`作业收集的图空间统计信息。 | + | [SHOW TAGS/EDGES](../3.ngql-guide/7.general-query-statements/6.show/15.show-tags-edges.md) | `SHOW TAGS \| EDGES` | `SHOW TAGS`、`SHOW EDGES` | 显示当前图空间内的所有Tag/Edge type。 | + | [SHOW USERS](../3.ngql-guide/7.general-query-statements/6.show/16.show-users.md) | `SHOW USERS` | `SHOW USERS` | 显示用户信息。 | + | [SHOW SESSIONS](../3.ngql-guide/7.general-query-statements/6.show/17.show-sessions.md) | `SHOW SESSIONS ` | ` SHOW SESSIONS` | 显示所有会话信息。 | + | [SHOW SESSIONS](../3.ngql-guide/7.general-query-statements/6.show/17.show-sessions.md) | `SHOW SESSION ` | `SHOW SESSION 1623304491050858` | 指定会话ID进行查看。 | + | [SHOW QUERIES](../3.ngql-guide/7.general-query-statements/6.show/18.show-queries.md) | `SHOW [ALL] QUERIES` | `SHOW QUERIES` | 查看当前Session中正在执行的查询请求信息。 | + | [SHOW META LEADER](../3.ngql-guide/7.general-query-statements/6.show/19.show-meta-leader.md) | `SHOW META LEADER` | `SHOW META LEADER` | 显示当前Meta集群的leader信息。 | + + + +## 子句和选项 + +| 子句 | 语法 | 示例 | 说明 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| [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` | 查找所有连接到player100的点,并根据他们的姓名进行分组,返回姓名的出现次数。 | +| [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` | 从排序结果中返回第2行开始的3行数据。 | +| [SKIP](../3.ngql-guide/8.clauses-and-options/limit.md) | `RETURN [SKIP ] [LIMIT ]` | `MATCH (v:player{name:"Tim Duncan"}) --> (v2) RETURN v2.name AS Name, v2.age AS Age ORDER BY Age DESC SKIP 1` | 用户可以单独使用`SKIP `设置偏移量,后面不需要添加`LIMIT `。 | +| [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` | `ORDER BY`子句指定输出结果的排序规则。 | +| [RETURN](../3.ngql-guide/8.clauses-and-options/return.md) | `RETURN {\|\|.\|.\|...}` | `MATCH (v:player) RETURN v.name, v.age LIMIT 3` | 返回点的属性为`name`和`age`的前三行值。 | +| [TTL](../3.ngql-guide/8.clauses-and-options/ttl-options.md) | ``CREATE TAG ( , , ...) ttl_duration= , ttl_col = `` | `CREATE TAG t2(a int, b int, c string) ttl_duration= 100, ttl_col = "a"` | 创建Tag并设置TTL选项。 | +| [WHERE](../3.ngql-guide/8.clauses-and-options/where.md) | `WHERE {. {>\|==\|<\|...} ...}` | `MATCH (v:player) WHERE v.name == "Tim Duncan" XOR (v.age < 30 AND v.name == "Yao Ming") OR NOT (v.name == "Yao Ming" OR v.name == "Tim Duncan") RETURN v.name, v.age` | `WHERE`子句可以根据条件过滤输出结果,通常用于`GO`和`LOOKUP`语句,`MATCH`和`WITH`语句。 | +| [YIELD](../3.ngql-guide/8.clauses-and-options/yield.md) | `YIELD [DISTINCT] [AS ] [, [AS ] ...] [WHERE ];` | `GO FROM "player100" OVER follow YIELD dst(edge) AS ID \| FETCH PROP ON player $-.ID YIELD player.age AS Age \| YIELD AVG($-.Age) as Avg_age, count(*)as Num_friends` | 查找player100关注的player,并计算他们的平均年龄。 | +| [WITH](../3.ngql-guide/8.clauses-and-options/with.md) | `MATCH $expressions WITH {nodes()\|labels()\|...}` | `MATCH p=(v:player{name:"Tim Duncan"})--() WITH nodes(p) AS n UNWIND n AS n1 RETURN DISTINCT n1` | `WITH`子句可以获取并处理查询前半部分的结果,并将处理结果作为输入传递给查询的后半部分。 | + + + +## 图空间语句 + +| 语句 | 语法 | 示例 | 说明 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | ----------------------------------------------------- | ------------------------------------------------------------ | +| [CREATE SPACE](../3.ngql-guide/9.space-statements/1.create-space.md) | `CREATE SPACE [IF NOT EXISTS] ( [partition_num = ,] [replica_factor = ,] vid_type = {FIXED_STRING()\| INT[64]} ) [COMMENT = '']` | `CREATE SPACE my_space_1 (vid_type=FIXED_STRING(30))` | 创建一个新的图空间。 | +| [CREATE SPACE](../3.ngql-guide/9.space-statements/1.create-space.md) | `CREATE SPACE AS ` | `CREATE SPACE my_space_4 as my_space_3` | 克隆现有图空间的Schema | +| [USE](../3.ngql-guide/9.space-statements/2.use-space.md) | `USE ` | `USE space1` | 指定一个图空间,或切换到另一个图空间,将其作为后续查询的工作空间。 | +| [SHOW SPACES](../3.ngql-guide/9.space-statements/3.show-spaces.md) | `SHOW SPACES` | `SHOW SPACES` | 列出Nebula Graph示例中的所有图空间。 | +| [DESCRIBE SPACE](../3.ngql-guide/9.space-statements/4.describe-space.md) | `DESC[RIBE] SPACE ` | `DESCRIBE SPACE basketballplayer` | 显示指定图空间的信息。 | +| [DROP SPACE](../3.ngql-guide/9.space-statements/5.drop-space.md) | `DROP SPACE [IF EXISTS] ` | `DROP SPACE basketballplayer` | 删除指定图空间的所有内容。 | + + + +## TAG语句 + +| 语句 | 语法 | 示例 | 说明 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| [CREATE TAG](../3.ngql-guide/10.tag-statements/1.create-tag.md) | `CREATE TAG [IF NOT EXISTS] ( [NULL \| NOT NULL] [DEFAULT ] [COMMENT ''] [{, [NULL \| NOT NULL] [DEFAULT ] [COMMENT '']} ...] ) [TTL_DURATION = ] [TTL_COL = ] [COMMENT = ''] ` | `CREATE TAG woman(name string, age int, married bool, salary double, create_time timestamp) TTL_DURATION = 100, TTL_COL = "create_time"` | 通过指定名称创建一个Tag。 | +| [DROP TAG](../3.ngql-guide/10.tag-statements/2.drop-tag.md) | `DROP TAG [IF EXISTS] ` | `CREATE TAG test(p1 string, p2 int)` | 删除当前工作空间内所有点上的指定Tag。 | +| [ALTER TAG](../3.ngql-guide/10.tag-statements/3.alter-tag.md) | `ALTER TAG [, alter_definition] ...] [ttl_definition [, ttl_definition] ... ] [COMMENT = '']` | `ALTER TAG t1 ADD (p3 int, p4 string)` | 修改Tag的结构。例如增删属性、修改数据类型,也可以为属性设置、修改[TTL](../3.ngql-guide/8.clauses-and-options/ttl-options.md(Time-To-Live)。 | +| [SHOW TAGS](../3.ngql-guide/10.tag-statements/4.show-tags.md) | `SHOW TAGS` | `SHOW TAGS` | 显示当前图空间内的所有Tag名称。 | +| [DESCRIBE TAG](../3.ngql-guide/10.tag-statements/5.describe-tag.md) | `DESC[RIBE] TAG ` | `DESCRIBE TAG player` | 指定Tag的详细信息,例如字段名称、数据类型等。 | +| [DELETE TAG](../3.ngql-guide/10.tag-statements/6.delete-tag.md) | `DELETE TAG FROM ` | `DELETE TAG test1 FROM "test"` | 删除指定点上的指定Tag。 | + + + +## Edge type语句 + +| 语句 | 语法 | 示例 | 说明 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | --------------------------------------------------- | +| [CREATE EDGE](../3.ngql-guide/11.edge-type-statements/1.create-edge.md) | `CREATE EDGE [IF NOT EXISTS] ( [NULL \| NOT NULL] [DEFAULT ] [COMMENT ''] [{, [NULL \| NOT NULL] [DEFAULT ] [COMMENT '']} ...] ) [TTL_DURATION = ] [TTL_COL = ] [COMMENT = ''] ` | `CREATE EDGE e1(p1 string, p2 int, p3 timestamp) TTL_DURATION = 100, TTL_COL = "p2"` | 指定名称创建一个Edge type。 | +| [DROP EDGE](../3.ngql-guide/11.edge-type-statements/2.drop-edge.md) | `DROP EDGE [IF EXISTS] ` | `DROP EDGE e1` | 删除当前工作空间内的指定Edge type。 | +| [ALTER EDGE](../3.ngql-guide/11.edge-type-statements/3.alter-edge.md) | `ALTER EDGE [, alter_definition] ...] [ttl_definition [, ttl_definition] ... ] [COMMENT = '']` | `ALTER EDGE e1 ADD (p3 int, p4 string)` | 修改Edge type的结构。 | +| [SHOW EDGES](../3.ngql-guide/11.edge-type-statements/4.show-edges.md) | `SHOW EDGES` | `SHOW EDGES` | 显示当前图空间内的所有Edge type名称。 | +| [DESCRIBE EDGE](../3.ngql-guide/11.edge-type-statements/5.describe-edge.md) | `DESC[RIBE] EDGE ` | `DESCRIBE EDGE follow` | 指定Edge type的详细信息,例如字段名称、数据类型等。 | + + + +## 点语句 + +| 语句 | 语法 | 示例 | 说明 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| [INSERT VERTEX](../3.ngql-guide/12.vertex-statements/1.insert-vertex.md) | `INSERT VERTEX [IF NOT EXISTS] () [, (), ...] {VALUES \| VALUE} VID: ([, ])` | `INSERT VERTEX t2 (name, age) VALUES "13":("n3", 12), "14":("n4", 8)` | 在Nebula Graph实例的指定图空间中插入一个或多个点。 | +| [DELETE VERTEX](../3.ngql-guide/12.vertex-statements/4.delete-vertex.md) | `DELETE VERTEX [, ...]` | `DELETE VERTEX "team1"` | 删除点,以及点关联的出边和入边。 | +| [UPDATE VERTEX](../3.ngql-guide/12.vertex-statements/2.update-vertex.md) | `UPDATE VERTEX ON SET [WHEN ] [YIELD ]` | `UPDATE VERTEX ON player "player101" SET age = age + 2 ` | 修改点上Tag的属性值。 | +| [UPSERT VERTEX](../3.ngql-guide/12.vertex-statements/3.upsert-vertex.md) | `UPSERT VERTEX ON SET [WHEN ] [YIELD ]` | `UPSERT VERTEX ON player "player667" SET age = 31` | 结合`UPDATE`和`INSERT`,如果点存在,会修改点的属性值;如果点不存在,会插入新的点。 | + + + +## 边语句 + +| 语句 | 语法 | 示例 | 说明 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| [INSERT EDGE](../3.ngql-guide/13.edge-statements/1.insert-edge.md) | `INSERT EDGE [IF NOT EXISTS] ( ) {VALUES \| VALUE} -> [@] : ( ) [, -> [@] : ( ), ...]` | `INSERT EDGE e2 (name, age) VALUES "11"->"13":("n1", 1)` | 在Nebula Graph实例的指定图空间中插入一条或多条边。 | +| [DELETE EDGE](../3.ngql-guide/12.vertex-statements/3.upsert-vertex.md) | `DELETE EDGE -> [@] [, -> [@] ...]` | `DELETE EDGE serve "player100" -> "team204"@0` | 删除边。一次可以删除一条或多条边。 | +| [UPDATE EDGE](../3.ngql-guide/13.edge-statements/2.update-edge.md) | `UPDATE EDGE ON -> [@] SET [WHEN ] [YIELD ]` | `UPDATE EDGE ON serve "player100" -> "team204"@0 SET start_year = start_year + 1` | 修改边上Edge type的属性。 | +| [UPSERT EDGE](../3.ngql-guide/12.vertex-statements/3.upsert-vertex.md) | `UPSERT EDGE ON -> [@rank] SET [WHEN ] [YIELD ]` | `UPSERT EDGE on serve "player666" -> "team200"@0 SET end_year = 2021` | 结合`UPDATE`和`INSERT`,如果边存在,会更新边的属性;如果边不存在,会插入新的边。 | + + + +## 索引 + +* 原生索引 + + > 索引配合`LOOKUP`和`MATCH`语句使用。 + + | 语句 | 语法 | 示例 | 说明 | + | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------- | ------------------------------------------------------------ | + | [CREATE INDEX](../3.ngql-guide/14.native-index-statements/1.create-native-index.md) | `CREATE {TAG \| EDGE} INDEX [IF NOT EXISTS] ON { \| } ([]) [COMMENT = '']` | `CREATE TAG INDEX player_index on player()` | 对Tag、EdgeType或其属性创建原生索引。 | + | [SHOW CREATE INDEX](../3.ngql-guide/14.native-index-statements/2.1.show-create-index.md) | `SHOW CREATE {TAG \| EDGE} INDEX ` | `show create tag index index_2` | 创建Tag或者Edge type时使用的nGQL语句,其中包含索引的详细信息,例如其关联的属性。 | + | [SHOW INDEXES](../3.ngql-guide/14.native-index-statements/2.show-native-indexes.md) | `SHOW {TAG \| EDGE} INDEXES` | `SHOW TAG INDEXES` | 列出当前图空间内的所有Tag和Edge type(包括属性)的索引。 | + | [DESCRIBE INDEX](../3.ngql-guide/14.native-index-statements/3.describe-native-index.md) | `DESCRIBE {TAG \| EDGE} INDEX ` | `DESCRIBE TAG INDEX player_index_0` | 查看指定索引的信息,包括索引的属性名称(Field)和数据类型(Type)。 | + | [REBUILD INDEX](../3.ngql-guide/14.native-index-statements/4.rebuild-native-index.md) | `REBUILD {TAG \| EDGE} INDEX []` | `REBUILD TAG INDEX single_person_index` | 重建索引。索引功能不会自动对其创建之前已存在的存量数据生效。 | + | [SHOW INDEX STATUS](../3.ngql-guide/14.native-index-statements/5.show-native-index-status.md) | `SHOW {TAG \| EDGE} INDEX STATUS` | `SHOW TAG INDEX STATUS` | 查看索引名称和对应的状态。 | + | [DROP INDEX](../3.ngql-guide/14.native-index-statements/6.drop-native-index.md) | `DROP {TAG \| EDGE} INDEX [IF EXISTS] ` | `DROP TAG INDEX player_index_0` | 删除当前图空间中已存在的索引。 | + + + +* [全文索引](../4.deployment-and-installation/6.deploy-text-based-index/2.deploy-es.md) + + | 语法 | 示例 | 说明 | + | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | + | `SIGN IN TEXT SERVICE [( [,, ]), (), ...]` | `SIGN IN TEXT SERVICE (127.0.0.1:9200)` | Nebula Graph的全文索引是基于[Elasticsearch](https://en.wikipedia.org/wiki/Elasticsearch)实现,部署Elasticsearch集群之后,可以使用`SIGN IN`语句登录Elasticsearch客户端。 | + | `SHOW TEXT SEARCH CLIENTS` | `SHOW TEXT SEARCH CLIENTS` | 列出文本搜索客户端。 | + | `SIGN OUT TEXT SERVICE` | `SIGN OUT TEXT SERVICE` | 退出所有文本搜索客户端。 | + | `CREATE FULLTEXT {TAG \| EDGE} INDEX ON { \| } ([])` | `CREATE FULLTEXT TAG INDEX nebula_index_1 ON player(name)` | 创建全文索引。 | + | `SHOW FULLTEXT INDEXES` | `SHOW FULLTEXT INDEXES` | 显示全文索引。 | + | `REBUILD FULLTEXT INDEX` | `REBUILD FULLTEXT INDEX` | 重建全文索引。 | + | `DROP FULLTEXT INDEX ` | `DROP FULLTEXT INDEX nebula_index_1` | 删除全文索引。 | + | `LOOKUP ON { \| } WHERE [YIELD ]` | `LOOKUP ON player WHERE FUZZY(player.name, "Tim Dunncan", AUTO, OR) YIELD player.name` | 使用查询选项。 | + + + +## 子图和路径 + +| 类型 | 语法 | 示例 | 说明 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| [子图](../3.ngql-guide/16.subgraph-and-path/1.get-subgraph.md) | `GET SUBGRAPH [WITH PROP] [ STEPS] FROM {, ...} [{IN \| OUT \| BOTH} , ...] [YIELD [VERTICES AS ] [,EDGES AS ]] ` | `GET SUBGRAPH 1 STEPS FROM "player100" YIELD VERTICES AS nodes, EDGES AS relationships` | 指定Edge type的起始点可以到达的点和边的信息,返回子图信息。 | +| [路径](../3.ngql-guide/16.subgraph-and-path/2.find-path.md) | `FIND { SHORTEST \| ALL \| NOLOOP } PATH [WITH PROP] FROM TO
OVER [REVERSELY \| BIDIRECT] [] [UPTO STEPS] [\| ORDER BY $-.path] [\| LIMIT ]` | `FIND SHORTEST PATH FROM "player102" TO "team204" OVER *` | 查找指定起始点和目的点之间的路径。返回的路径格式类似于`()-[:@]->(` | `EXPLAIN format="row" SHOW TAGS`
`EXPLAIN format="dot" SHOW TAGS` | 输出nGQL语句的执行计划,但不会执行nGQL语句。 | +| [PROFILE](../3.ngql-guide/17.query-tuning-statements/1.explain-and-profile.md) | `PROFILE [format="row" \| "dot"] ` | `PROFILE format="row" SHOW TAGS`
`EXPLAIN format="dot" SHOW TAGS` | 执行nGQL语句,然后输出执行计划和执行概要。 | + + + +## 运维 + +* [BALANCE](../3.ngql-guide/18.operation-and-maintenance-statements/2.balance-syntax.md) + + | 语法 | 说明 | + | :-------------------------------- | :----------------------------------------------------------- | + | `BALANCE DATA` | 启动任务均衡分布Nebula Graph集群里的所有分片。该命令会返回任务ID(`balance_id`)。 | + | `BALANCE DATA ` | 显示`BALANCE DATA`任务的状态。 | + | `BALANCE DATA STOP` | 停止`BALANCE DATA`任务。 | + | `BALANCE DATA REMOVE ` | 在Nebula Graph集群中扫描并解绑指定的Storage主机。 | + | `BALANCE LEADER` | 在Nebula Graph集群中均衡分布leader。 | + +* [作业管理](../3.ngql-guide/18.operation-and-maintenance-statements/4.job-statements.md) + + | 语法 | 说明 | + | -------------------- | ------------------------------------------------------------ | + | `SUBMIT JOB COMPACT` | 触发RocksDB的长耗时`compact`操作。 | + | `SUBMIT JOB FLUSH` | 将内存中的RocksDB memfile写入硬盘。 | + | `SUBMIT JOB STATS` | 启动一个作业,该作业对当前图空间进行统计。作业完成后,用户可以使用`SHOW STATS`语句列出统计结果。 | + | `SHOW JOB ` | 显示当前图空间内指定作业和相关任务的信息。Meta服务将`SUBMIT JOB`请求解析为多个任务,然后分配给进程nebula-storaged。 | + | `SHOW JOBS` | 列出当前图空间内所有未过期的作业。 | + | `STOP JOB` | 停止当前图空间内未完成的作业。 | + | `RECOVER JOB` | 重新执行当前图空间内失败的作业,并返回已恢复的作业数量。 | + +* [终止查询](../3.ngql-guide/18.operation-and-maintenance-statements/6.kill-query.md) + + | 语法 | 示例 | 说明 | + | --------------------------------------------------- | ----------------------------------------------- | -------------------------------------------- | + | `KILL QUERY (session=, plan=)` | `KILL QUERY(SESSION=1625553545984255,PLAN=163)` | 在一个会话中执行命令终止另一个会话中的查询。 | + + diff --git a/docs-2.0/2.quick-start/dataset-for-crud.png b/docs-2.0/2.quick-start/dataset-for-crud.png new file mode 100644 index 00000000000..6b41fe5dd9f Binary files /dev/null and b/docs-2.0/2.quick-start/dataset-for-crud.png differ diff --git a/docs-2.0/20.appendix/0.FAQ.md b/docs-2.0/20.appendix/0.FAQ.md index 7e57b592790..c446be2c926 100644 --- a/docs-2.0/20.appendix/0.FAQ.md +++ b/docs-2.0/20.appendix/0.FAQ.md @@ -23,7 +23,9 @@ Nebula Graph一直在持续开发,功能或操作的行为可能会有变化 !!! compatibility "`X`版本兼容性" Nebula Graph {{ nebula.release }} 与 历史版本 (包括 Nebula Graph 1.x 和 2.0-RC) 的数据格式、客户端通信协议均**双向不兼容**。 - 数据格式升级参见[升级 Nebula Graph 历史版本至 v{{nebula.release}}](../4.deployment-and-installation/3.upgrade-nebula-graph/upgrade-nebula-graph-to-250.md)。 + + 数据格式升级参见[升级 Nebula Graph 历史版本至 v{{nebula.release}}](../4.deployment-and-installation/3.upgrade-nebula-graph/upgrade-nebula-graph-to-260.md)。 + 客户端与工具均需要[下载对应版本](../20.appendix/6.eco-tool-version.md)。 !!! compatibility "`Y`版本兼容性" @@ -32,6 +34,10 @@ Nebula Graph一直在持续开发,功能或操作的行为可能会有变化 ## 关于执行 +### 为什么Nebula Graph 2.6.0的返回结果每行之间没有横线分隔了? + +这是Nebula Console 2.6.0版本的变动造成的,不是Nebula Graph内核的变更,不影响返回数据本身的内容。 + ### 关于悬挂边 悬挂边 (Dangling edge) 是指一条边的起点或者终点在数据库中不存在。 @@ -72,11 +78,11 @@ Nebula Graph {{ nebula.release }} 的数据模型中,允许存在"悬挂边" ```nGQL nebula> SHOW SPACES; -+-------------------+ -| Name | -+-------------------+ -| basketballplayer | -+-------------------+ ++--------------------+ +| Name | ++--------------------+ +| "basketballplayer" | ++--------------------+ Got 1 rows (time spent 1235/1934 us) ``` @@ -309,6 +315,10 @@ Nebula Graph {{ nebula.release }} 未提供运维命令以实现自动扩缩容 - metad 的扩容和缩容: metad 不支持扩缩容,也不支持迁移到新机器,也不要增加新的 metad 进程。 + !!! note + + 用户可以使用[脚本工具](https://github.com/vesoft-inc/nebula/blob/master/scripts/meta-transfer-tools.sh)迁移meta服务,但是需要自行修改Graph服务和Storage服务的配置文件中的Meta设置。 + - graphd 的缩容: 将该graphd 的 ip 从 client 的代码中移除,关闭该 graphd 进程。 - graphd 的扩容: 在新机器上准备 graphd 二进制文件和配置文件,在配置文件中修改或增加已在运行的 metad 地址,启动 graphd 进程。 diff --git a/docs-2.0/20.appendix/6.eco-tool-version.md b/docs-2.0/20.appendix/6.eco-tool-version.md index a3cf08bfd8e..8cb3a24d6aa 100644 --- a/docs-2.0/20.appendix/6.eco-tool-version.md +++ b/docs-2.0/20.appendix/6.eco-tool-version.md @@ -58,9 +58,9 @@ Nebula Explorer(简称Explorer)是一款可以通过Web访问的图探索可 Nebula Exchange(简称Exchange)是一款Apache Spark™应用,用于在分布式环境中将集群中的数据批量迁移到Nebula Graph中,能支持多种不同格式的批式数据和流式数据的迁移。详情请参见[什么是Nebula Exchange](../nebula-exchange/about-exchange/ex-ug-what-is-exchange.md)。 -|Nebula Graph版本|[Exchange](https://github.com/vesoft-inc/nebula-spark-utils/tree/{{exchange.branch}}/nebula-exchange)版本(commit id)| +|Nebula Graph版本|Exchange版本(commit id)| |:---|:---| -| {{ nebula.release }} | {{exchange.release}}(3c0f4c6) | +| {{ nebula.release }} | {{exchange.release}}(cb83202) | ## Nebula Operator @@ -76,21 +76,21 @@ Nebula Importer(简称Importer)是一款Nebula Graph的CSV文件导入工具 |Nebula Graph版本|[Importer](https://github.com/vesoft-inc/nebula-importer/tree/{{importer.branch}})版本(commit id)| |:---|:---| -| {{ nebula.release }} | {{importer.release}}(5c7417d) | +| {{ nebula.release }} | {{importer.release}}(43234f3) | ## Nebula Spark Connector Nebula Spark Connector是一个Spark连接器,提供通过Spark标准形式读写Nebula Graph数据的能力。Nebula Spark Connector由Reader和Writer两部分组成。详情请参见[什么是Nebula Spark Connector](../nebula-spark-connector.md)。 -|Nebula Graph版本|[Spark Connector](https://github.com/vesoft-inc/nebula-spark-utils/tree/{{sparkconnector.branch}}/nebula-spark-connector)版本(commit id)| +|Nebula Graph版本|Spark Connector版本(commit id)| |:---|:---| -| {{ nebula.release }} | {{sparkconnector.release}}(3c0f4c6) | +| {{ nebula.release }} | {{sparkconnector.release}}(2c61ca5) | ## Nebula Flink Connector Nebula Flink Connector是一款帮助Flink用户快速访问Nebula Graph的连接器,支持从Nebula Graph图数据库中读取数据,或者将其他外部数据源读取的数据写入Nebula Graph图数据库。详情请参见[什么是Nebula Flink Connector](../nebula-flink-connector.md)。 -|Nebula Graph版本|[Flink Connector](https://github.com/vesoft-inc/nebula-flink-connector/tree/{{flinkconnector.branch}})版本(commit id)| +|Nebula Graph版本|Flink Connector版本(commit id)| |:---|:---| | {{ nebula.release }} | {{flinkconnector.release}}(49b8f3d) | @@ -98,25 +98,25 @@ Nebula Flink Connector是一款帮助Flink用户快速访问Nebula Graph的连 Nebula Algorithm(简称Algorithm)是一款基于[GraphX](https://spark.apache.org/graphx/)的Spark应用程序,通过提交Spark任务的形式使用完整的算法工具对Nebula Graph数据库中的数据执行图计算,也可以通过编程形式调用lib库下的算法针对DataFrame执行图计算。详情请参见[什么是Nebula Algorithm](../nebula-algorithm.md)。 -|Nebula Graph版本|[Algorithm](https://github.com/vesoft-inc/nebula-spark-utils/tree/{{algorithm.branch}}/nebula-algorithm)版本(commit id)| +|Nebula Graph版本|Algorithm版本(commit id)| |:---|:---| -| {{ nebula.release }} | {{algorithm.release}}(3c0f4c6) | +| {{ nebula.release }} | {{algorithm.release}}(2c61ca5) | ## Nebula Console Nebula Console是Nebula Graph的原生CLI客户端。如何使用请参见[连接Nebula Graph](../2.quick-start/3.connect-to-nebula-graph.md)。 -|Nebula Graph版本|[Console](https://github.com/vesoft-inc/nebula-console)版本(commit id)| +|Nebula Graph版本|Console版本(commit id)| |:---|:---| -| {{ nebula.release }} | {{console.release}}(3ce5151) | +| {{ nebula.release }} | {{console.release}}(0834198) | ## Nebula Docker Compose Docker Compose可以快速部署Nebula Graph集群。如何使用请参见[Docker Compose部署Nebula Graph](../4.deployment-and-installation/2.compile-and-install-nebula-graph/3.deploy-nebula-graph-with-docker-compose.md)。 -|Nebula Graph版本|[Docker Compose](https://github.com/vesoft-inc/nebula-docker-compose/tree/master)版本(commit id)| +|Nebula Graph版本|Docker Compose版本(commit id)| |:---|:---| -| {{ nebula.release }} | {{dockercompose.release}}(d42231f) | +| {{ nebula.release }} | {{dockercompose.release}}(a6e9d78) | diff --git a/docs-2.0/3.ngql-guide/14.native-index-statements/2.1.show-create-index.md b/docs-2.0/3.ngql-guide/14.native-index-statements/2.1.show-create-index.md index a776c9b2cc2..0df901dd55e 100644 --- a/docs-2.0/3.ngql-guide/14.native-index-statements/2.1.show-create-index.md +++ b/docs-2.0/3.ngql-guide/14.native-index-statements/2.1.show-create-index.md @@ -14,18 +14,19 @@ SHOW CREATE {TAG | EDGE} INDEX ; ```ngql nebula> SHOW TAG INDEXES; -+------------------+--------------+-----------------+ -| "player_index_0" | "player" | ["name"] | -+------------------+--------------+-----------------+ -| "player_index_1" | "player" | ["name", "age"] | -+------------------+--------------+-----------------+ ++------------------+----------+----------+ +| Index Name | By Tag | Columns | ++------------------+----------+----------+ +| "player_index_0" | "player" | [] | +| "player_index_1" | "player" | ["name"] | ++------------------+----------+----------+ nebula> SHOW CREATE TAG INDEX player_index_1; +------------------+--------------------------------------------------+ | Tag Index Name | Create Tag Index | +------------------+--------------------------------------------------+ | "player_index_1" | "CREATE TAG INDEX `player_index_1` ON `player` ( | -| | `name(20)` | +| | `name`(20) | | | )" | +------------------+--------------------------------------------------+ ``` diff --git a/docs-2.0/3.ngql-guide/14.native-index-statements/2.show-native-indexes.md b/docs-2.0/3.ngql-guide/14.native-index-statements/2.show-native-indexes.md index f6618a8b0fd..a2734488b8c 100644 --- a/docs-2.0/3.ngql-guide/14.native-index-statements/2.show-native-indexes.md +++ b/docs-2.0/3.ngql-guide/14.native-index-statements/2.show-native-indexes.md @@ -16,11 +16,8 @@ nebula> SHOW TAG INDEXES; | Index Name | By Tag | Columns | +------------------+--------------+-----------------+ | "fix" | "fix_string" | ["p1"] | -+------------------+--------------+-----------------+ | "player_index_0" | "player" | ["name"] | -+------------------+--------------+-----------------+ | "player_index_1" | "player" | ["name", "age"] | -+------------------+--------------+-----------------+ | "var" | "var_string" | ["p1"] | +------------------+--------------+-----------------+ @@ -35,4 +32,4 @@ nebula> SHOW EDGE INDEXES; !!! Compatibility "历史版本兼容性" - Nebula Graph 2.0.1中, `SHOW TAG/EDGE INDEXES` 语句仅返回 `Names`。 \ No newline at end of file + Nebula Graph 2.0.1中, `SHOW TAG/EDGE INDEXES` 语句仅返回 `Names`。 diff --git a/docs-2.0/3.ngql-guide/14.native-index-statements/3.describe-native-index.md b/docs-2.0/3.ngql-guide/14.native-index-statements/3.describe-native-index.md index 6e5089b33df..61021f46f32 100644 --- a/docs-2.0/3.ngql-guide/14.native-index-statements/3.describe-native-index.md +++ b/docs-2.0/3.ngql-guide/14.native-index-statements/3.describe-native-index.md @@ -23,7 +23,6 @@ nebula> DESCRIBE TAG INDEX player_index_1; | Field | Type | +--------+--------------------+ | "name" | "fixed_string(10)" | -+--------+--------------------+ | "age" | "int64" | +--------+--------------------+ -``` \ No newline at end of file +``` diff --git a/docs-2.0/3.ngql-guide/14.native-index-statements/4.rebuild-native-index.md b/docs-2.0/3.ngql-guide/14.native-index-statements/4.rebuild-native-index.md index 6ad98396897..c3ab680e806 100644 --- a/docs-2.0/3.ngql-guide/14.native-index-statements/4.rebuild-native-index.md +++ b/docs-2.0/3.ngql-guide/14.native-index-statements/4.rebuild-native-index.md @@ -49,11 +49,8 @@ nebula> SHOW JOB 31; | Job Id(TaskId) | Command(Dest) | Status | Start Time | Stop Time | +----------------+---------------------+------------+-------------------------+-------------------------+ | 31 | "REBUILD_TAG_INDEX" | "FINISHED" | 2021-07-07T09:04:24.000 | 2021-07-07T09:04:24.000 | -+----------------+---------------------+------------+-------------------------+-------------------------+ | 0 | "storaged1" | "FINISHED" | 2021-07-07T09:04:24.000 | 2021-07-07T09:04:28.000 | -+----------------+---------------------+------------+-------------------------+-------------------------+ | 1 | "storaged2" | "FINISHED" | 2021-07-07T09:04:24.000 | 2021-07-07T09:04:28.000 | -+----------------+---------------------+------------+-------------------------+-------------------------+ | 2 | "storaged0" | "FINISHED" | 2021-07-07T09:04:24.000 | 2021-07-07T09:04:28.000 | +----------------+---------------------+------------+-------------------------+-------------------------+ ``` diff --git a/docs-2.0/3.ngql-guide/14.native-index-statements/5.show-native-index-status.md b/docs-2.0/3.ngql-guide/14.native-index-statements/5.show-native-index-status.md index 6736a2e6a19..1d8efc17449 100644 --- a/docs-2.0/3.ngql-guide/14.native-index-statements/5.show-native-index-status.md +++ b/docs-2.0/3.ngql-guide/14.native-index-statements/5.show-native-index-status.md @@ -29,7 +29,6 @@ nebula> SHOW TAG INDEX STATUS; | Name | Index Status | +----------------------+--------------+ | "player_index_0" | "FINISHED" | -+----------------------+--------------+ | "player_index_1" | "FINISHED" | +----------------------+--------------+ -``` \ No newline at end of file +``` diff --git a/docs-2.0/3.ngql-guide/14.native-index-statements/README.md b/docs-2.0/3.ngql-guide/14.native-index-statements/README.md index 2f8b6662c37..f6a45491e74 100644 --- a/docs-2.0/3.ngql-guide/14.native-index-statements/README.md +++ b/docs-2.0/3.ngql-guide/14.native-index-statements/README.md @@ -12,10 +12,6 @@ Nebula Graph支持两种类型索引:原生索引和全文索引。 - 支持创建同一个Tag或Edge type的多个属性的索引(复合索引),但是不能跨Tag或Edge type。 -- 复合索引可以实现部分匹配检索,遵循最左匹配原则。详情请参见[LOOKUP FAQ](../7.general-query-statements/5.lookup.md#faq)。 - -- [LOOKUP](../7.general-query-statements/5.lookup.md)不支持`CONTAINS`和`STARTS WITH`等字符串操作符。 - ### 原生索引操作 - [CREATE INDEX](1.create-native-index.md) 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 f22c174dc5c..3cacc705196 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 @@ -21,7 +21,7 @@ ### 创建全文索引 ```ngql -CREATE {TAG | EDGE} INDEX ON { | } ([]); +CREATE FULLTEXT {TAG | EDGE} INDEX ON { | } ([]); ``` ### 显示全文索引 @@ -65,7 +65,7 @@ LOOKUP ON { | } WHERE [YIELD ]; - `fuzziness`:可选项。允许匹配的最大编辑距离。默认值为`AUTO`。查看其他可选值和更多信息,请参见[Elasticsearch官方文档](https://www.elastic.co/guide/en/elasticsearch/reference/6.8/common-options.html#fuzziness)。 - `operator`:可选项。解释文本的布尔逻辑。可选值为`OR`(默认)和`and`。 - + - `row_limit`:可选项。指定要返回的行数。默认值为`100`。 - `timeout`:可选项。指定超时时间。单位:毫秒(ms)。默认值为`200`。 @@ -128,9 +128,7 @@ nebula> LOOKUP ON player WHERE PREFIX(player.name, "B"); | _vid | +-----------------+ | "Boris Diaw" | -+-----------------+ | "Ben Simmons" | -+-----------------+ | "Blake Griffin" | +-----------------+ @@ -139,9 +137,7 @@ nebula> LOOKUP ON player WHERE WILDCARD(player.name, "*ri*") YIELD player.name, | _vid | name | age | +-----------------+-----------------+-----+ | "Chris Paul" | "Chris Paul" | 33 | -+-----------------+-----------------+-----+ | "Boris Diaw" | "Boris Diaw" | 36 | -+-----------------+-----------------+-----+ | "Blake Griffin" | "Blake Griffin" | 30 | +-----------------+-----------------+-----+ @@ -164,9 +160,7 @@ nebula> LOOKUP ON player WHERE REGEXP(player.name, ".*"); | _vid | +---------------------+ | "Danny Green" | -+---------------------+ | "David West" | -+---------------------+ | "Russell Westbrook" | +---------------------+ ... 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 56169573880..072c8a9246a 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 @@ -6,9 +6,8 @@ ```ngql GET SUBGRAPH [WITH PROP] [ STEPS] FROM {, ...} -[IN , ...] -[OUT , ...] -[BOTH , ...]; +[{IN | OUT | BOTH} , ...] +[YIELD [VERTICES AS ] [,EDGES AS ]]; ``` - `WITH PROP`:展示属性。不添加本参数则隐藏属性。 @@ -19,6 +18,8 @@ GET SUBGRAPH [WITH PROP] [ STEPS] FROM {, ...} - `edge_type`:指定Edge type。可以用`IN`、`OUT`和`BOTH`来指定起始点上该Edge type的方向。默认为`BOTH`。 +- `YIELD`:定义需要返回的输出。可以仅返回点或边。必须设置别名。不使用`YIELD`定义输出结果时,默认返回`_vertices`和`_edges`。 + !!! note `GET SUBGRAPH`语句检索的路径类型为`trail`,即检索的路径只有点可以重复,边不可以重复。详情请参见[路径](../../1.introduction/2.1.path.md)。 @@ -27,58 +28,75 @@ GET SUBGRAPH [WITH PROP] [ STEPS] FROM {, ...} 以下面的示例图进行演示。 -![A sample graph for GET SUBGRAPH](https://docs-cdn.nebula-graph.com.cn/docs-2.0/2.quick-start/dataset-for-crud.png) +![A sample graph for GET SUBGRAPH](../../2.quick-start/dataset-for-crud.png) + +插入测试数据: -- 查询从点`player100`开始、0~1跳、所有Edge type的子图。 +```ngql +nebula> CREATE SPACE subgraph(partition_num=15, replica_factor=1, vid_type=fixed_string(30)); +nebula> USE subgraph; +nebula> CREATE TAG player(name string, age int); +nebula> CREATE TAG team(name string); +nebula> CREATE EDGE follow(degree int); +nebula> CREATE EDGE serve(start_year int, end_year int); +nebula> INSERT VERTEX player(name, age) VALUES "player100":("Tim Duncan", 42); +nebula> INSERT VERTEX player(name, age) VALUES "player101":("Tony Parker", 36); +nebula> INSERT VERTEX player(name, age) VALUES "player102":("LaMarcus Aldridge", 33); +nebula> INSERT VERTEX team(name) VALUES "team203":("Trail Blazers"), "team204":("Spurs"); +nebula> INSERT EDGE follow(degree) VALUES "player101" -> "player100":(95); +nebula> INSERT EDGE follow(degree) VALUES "player101" -> "player102":(90); +nebula> INSERT EDGE follow(degree) VALUES "player102" -> "player100":(75); +nebula> INSERT EDGE serve(start_year, end_year) VALUES "player101" -> "team204":(1999, 2018),"player102" -> "team203":(2006, 2015); +``` + +- 查询从点`player101`开始、0~1跳、所有Edge type的子图。 ```ngql - nebula> GET SUBGRAPH 1 STEPS FROM "player100"; - +-------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+ - | _vertices | _edges | + nebula> GET SUBGRAPH 1 STEPS FROM "player101" YIELD VERTICES AS nodes, EDGES AS relationships; +-------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+ - | [("player100" :player{})] | [[:serve "player100"->"team200" @0 {}], [:follow "player100"->"player101" @0 {}], [:follow "player100"->"player102" @0 {}]] | + | nodes | relationships | +-------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+ - | [("team200" :team{}), ("player101" :player{}), ("player102" :player{})] | [[:follow "player102"->"player101" @0 {}]] | + | [("player101" :player{})] | [[:serve "player101"->"team204" @0 {}], [:follow "player101"->"player100" @0 {}], [:follow "player101"->"player102" @0 {}]] | + | [("team204" :team{}), ("player100" :player{}), ("player102" :player{})] | [[:follow "player102"->"player100" @0 {}]] | +-------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+ ``` 返回的子图如下。 - ![GET SUBGRAPH FROM "player100"](https://docs-cdn.nebula-graph.com.cn/docs-2.0/3.ngql-guide/15.subgraph-and-path/subgraph-1.png) + ![GET SUBGRAPH FROM "player101"](subgraph-1.png) -- 查询从点`player100`开始、0~1跳、`follow`类型的入边的子图。 +- 查询从点`player101`开始、0~1跳、`follow`类型的入边的子图。 ```ngql - nebula> GET SUBGRAPH 1 STEPS FROM "player100" IN follow; - +---------------------------+--------+ - | _vertices | _edges | - +---------------------------+--------+ - | [("player100" :player{})] | [] | - +---------------------------+--------+ - | [] | [] | - +---------------------------+--------+ + nebula> GET SUBGRAPH 1 STEPS FROM "player101" IN follow YIELD VERTICES AS nodes, EDGES AS relationships; + +---------------------------+---------------+ + | nodes | relationships | + +---------------------------+---------------+ + | [("player101" :player{})] | [] | + | [] | [] | + +---------------------------+---------------+ ``` - 因为`player100`没有`follow`类型的入边。所以仅返回点`player100`。 + 因为`player101`没有`follow`类型的入边。所以仅返回点`player101`。 -- 查询从点`player100`开始、0~1跳、`serve`类型的出边的子图,同时展示边的属性。 +- 查询从点`player101`开始、0~1跳、`serve`类型的出边的子图,同时展示边的属性。 ```ngql - nebula> GET SUBGRAPH WITH PROP 1 STEPS FROM "player100" OUT serve; - +------------------------------------------------------+-------------------------------------------------------------------------+ - | _vertices | _edges | - +------------------------------------------------------+-------------------------------------------------------------------------+ - | [("player100" :player{age: 42, name: "Tim Duncan"})] | [[:serve "player100"->"team200" @0 {end_year: 2016, start_year: 1997}]] | - +------------------------------------------------------+-------------------------------------------------------------------------+ - | [("team200" :team{name: "Warriors"})] | [] | - +------------------------------------------------------+-------------------------------------------------------------------------+ + nebula> GET SUBGRAPH WITH PROP 1 STEPS FROM "player101" OUT serve YIELD VERTICES AS nodes, EDGES AS relationships; + +-------------------------------------------------------+-------------------------------------------------------------------------+ + | nodes | relationships | + +-------------------------------------------------------+-------------------------------------------------------------------------+ + | [("player101" :player{age: 36, name: "Tony Parker"})] | [[:serve "player101"->"team204" @0 {end_year: 2018, start_year: 1999}]] | + | [("team204" :team{name: "Spurs"})] | [] | + +-------------------------------------------------------+-------------------------------------------------------------------------+ ``` 返回的子图如下。 - ![GET SUBGRAPH FROM "100" OUT serve](https://docs-cdn.nebula-graph.com.cn/docs-2.0/3.ngql-guide/15.subgraph-and-path/subgraph-2.png) + ![GET SUBGRAPH FROM "101" OUT serve](subgraph-2.png) ## FAQ + ### 为什么返回结果中会出现超出`step_count`跳数之外的关系? 为了展示子图的完整性,会在满足条件的所有点上额外查询一跳。例如下图。 @@ -102,12 +120,11 @@ nebula> go 1 steps from "A" over follow; 查询到没有多余子图数据时会停止查询,且不会返回空值。 ```ngql -nebula> GET SUBGRAPH 100 STEPS FROM "player141" OUT follow; -+-------------------------------------------------------+--------------------------------------------+ -| _vertices | _edges | -+-------------------------------------------------------+--------------------------------------------+ -| [("player141" :player{age: 43, name: "Ray Allen"})] | [[:follow "player141"->"player124" @0 {}]] | -+-------------------------------------------------------+--------------------------------------------+ -| [("player124" :player{age: 33, name: "Rajon Rondo"})] | [[:follow "player124"->"player141" @0 {}]] | -+-------------------------------------------------------+--------------------------------------------+ +nebula> GET SUBGRAPH 100 STEPS FROM "player101" OUT follow YIELD VERTICES AS nodes, EDGES AS relationships; ++----------------------------------------------------+--------------------------------------------------------------------------------------+ +| nodes | relationships | ++----------------------------------------------------+--------------------------------------------------------------------------------------+ +| [("player101" :player{})] | [[:follow "player101"->"player100" @0 {}], [:follow "player101"->"player102" @0 {}]] | +| [("player100" :player{}), ("player102" :player{})] | [[:follow "player102"->"player100" @0 {}]] | ++----------------------------------------------------+--------------------------------------------------------------------------------------+ ``` 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 18c679d10e8..d1882003358 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 @@ -74,12 +74,10 @@ nebula> FIND ALL PATH FROM "player100" TO "team204" OVER * WHERE follow.degree i | path | +------------------------------------------------------------------------------+ | <("player100")-[:serve@0 {}]->("team204")> | -+------------------------------------------------------------------------------+ | <("player100")-[:follow@0 {}]->("player125")-[:serve@0 {}]->("team204")> | -+------------------------------------------------------------------------------+ | <("player100")-[:follow@0 {}]->("player101")-[:serve@0 {}]->("team204")> | +| ... | +------------------------------------------------------------------------------+ -... ``` ```ngql @@ -88,14 +86,11 @@ nebula> FIND NOLOOP PATH FROM "player100" TO "team204" OVER *; | path | +--------------------------------------------------------------------------------------------------------+ | <("player100")-[:serve@0 {}]->("team204")> | -+--------------------------------------------------------------------------------------------------------+ | <("player100")-[:follow@0 {}]->("player125")-[:serve@0 {}]->("team204")> | -+--------------------------------------------------------------------------------------------------------+ | <("player100")-[:follow@0 {}]->("player101")-[:serve@0 {}]->("team204")> | -+--------------------------------------------------------------------------------------------------------+ | <("player100")-[:follow@0 {}]->("player101")-[:follow@0 {}]->("player125")-[:serve@0 {}]->("team204")> | -+--------------------------------------------------------------------------------------------------------+ | <("player100")-[:follow@0 {}]->("player101")-[:follow@0 {}]->("player102")-[:serve@0 {}]->("team204")> | +| ... | +--------------------------------------------------------------------------------------------------------+ ``` diff --git a/docs-2.0/3.ngql-guide/16.subgraph-and-path/subgraph-1.png b/docs-2.0/3.ngql-guide/16.subgraph-and-path/subgraph-1.png new file mode 100644 index 00000000000..f513e29f149 Binary files /dev/null and b/docs-2.0/3.ngql-guide/16.subgraph-and-path/subgraph-1.png differ diff --git a/docs-2.0/3.ngql-guide/16.subgraph-and-path/subgraph-2.png b/docs-2.0/3.ngql-guide/16.subgraph-and-path/subgraph-2.png new file mode 100644 index 00000000000..e9f41079c96 Binary files /dev/null and b/docs-2.0/3.ngql-guide/16.subgraph-and-path/subgraph-2.png differ diff --git a/docs-2.0/3.ngql-guide/17.query-tuning-statements/1.explain-and-profile.md b/docs-2.0/3.ngql-guide/17.query-tuning-statements/1.explain-and-profile.md index 5c8a6887e0f..ab4930e8223 100644 --- a/docs-2.0/3.ngql-guide/17.query-tuning-statements/1.explain-and-profile.md +++ b/docs-2.0/3.ngql-guide/17.query-tuning-statements/1.explain-and-profile.md @@ -60,7 +60,6 @@ | Name | +--------+ | player | - +--------+ | team | +--------+ Got 2 rows (time spent 2038/2728 us) @@ -111,4 +110,4 @@ Execution Plan 将上述示例的DOT语言转换为Graphviz图,如下所示。 -![Graphviz graph of EXPLAIN SHOW TAGS](https://docs-cdn.nebula-graph.com.cn/docs-2.0/3.ngql-guide/16.query-tuning-statements/explain-show-tags.png) \ No newline at end of file +![Graphviz graph of EXPLAIN SHOW TAGS](https://docs-cdn.nebula-graph.com.cn/docs-2.0/3.ngql-guide/16.query-tuning-statements/explain-show-tags.png) diff --git a/docs-2.0/3.ngql-guide/18.operation-and-maintenance-statements/2.balance-syntax.md b/docs-2.0/3.ngql-guide/18.operation-and-maintenance-statements/2.balance-syntax.md index bf8bf60a994..83d5730cf5c 100644 --- a/docs-2.0/3.ngql-guide/18.operation-and-maintenance-statements/2.balance-syntax.md +++ b/docs-2.0/3.ngql-guide/18.operation-and-maintenance-statements/2.balance-syntax.md @@ -6,8 +6,8 @@ |语法|说明| |:---|:---| -|`BALANCE DATA`|启动任务均衡分布Nebula Graph集群里的所有分片。该命令会返回任务ID(`balance_id`)。| +|`BALANCE DATA`|启动任务均衡分布Nebula Graph集群中(或Group中)的所有分片。该命令会返回任务ID(`balance_id`)。| |`BALANCE DATA `|显示`BALANCE DATA`任务的状态。| |`BALANCE DATA STOP`|停止`BALANCE DATA`任务。| |`BALANCE DATA REMOVE `|在Nebula Graph集群中扫描并解绑指定的Storage主机。| -|`BALANCE LEADER`|在Nebula Graph集群中均衡分布leader。| +|`BALANCE LEADER`|在Nebula Graph集群中(或Group中)均衡分布leader。| diff --git a/docs-2.0/3.ngql-guide/18.operation-and-maintenance-statements/4.job-statements.md b/docs-2.0/3.ngql-guide/18.operation-and-maintenance-statements/4.job-statements.md index 1baa86d5e9c..e36283f349b 100644 --- a/docs-2.0/3.ngql-guide/18.operation-and-maintenance-statements/4.job-statements.md +++ b/docs-2.0/3.ngql-guide/18.operation-and-maintenance-statements/4.job-statements.md @@ -2,6 +2,10 @@ 在Storage服务上长期运行的任务称为作业,例如`COMPACT`、`FLUSH`和`STATS`。 如果图空间的数据量很大,这些作业可能耗时很长。作业管理可以帮助执行、查看、停止和恢复作业。 +!!! note + + 所有作业管理命令都需要先选择图空间后才能执行。 + ## SUBMIT JOB COMPACT `SUBMIT JOB COMPACT` 语句会触发 RocksDB 的长耗时 `compact` 操作。 @@ -49,31 +53,26 @@ nebula> SUBMIT JOB STATS; +------------+ | New Job Id | +------------+ -| 97 | +| 34 | +------------+ ``` ## SHOW JOB -Meta服务将`SUBMIT JOB`请求解析为多个任务,然后分配给进程nebula-storaged。`SHOW JOB `语句显示指定作业和相关任务的信息。 +Meta服务将`SUBMIT JOB`请求解析为多个任务,然后分配给进程nebula-storaged。`SHOW JOB `语句显示当前图空间内指定作业和相关任务的信息。 `job_id`在执行`SUBMIT JOB`语句时会返回。 ### 示例 ```ngql -nebula> SHOW JOB 96; -+----------------+---------------+------------+-------------------------+-------------------------+ -| Job Id(TaskId) | Command(Dest) | Status | Start Time | Stop Time | -+----------------+---------------+------------+-------------------------+-------------------------+ -| 96 | "FLUSH" | "FINISHED" | 2020-11-28T14:14:29.000 | 2020-11-28T14:14:29.000 | -+----------------+---------------+------------+-------------------------+-------------------------+ -| 0 | "storaged2" | "FINISHED" | 2020-11-28T14:14:29.000 | 2020-11-28T14:14:29.000 | -+----------------+---------------+-------------------------+------------+-------------------------+ -| 1 | "storaged0" | "FINISHED" | 2020-11-28T14:14:29.000 | 2020-11-28T14:14:29.000 | -+----------------+---------------+------------+-------------------------+-------------------------+ -| 2 | "storaged1" | "FINISHED" | 2020-11-28T14:14:29.000 | 2020-11-28T14:14:29.000 | -+----------------+---------------+------------+-------------------------+-------------------------+ +nebula> SHOW JOB 34; ++----------------+-----------------+------------+----------------------------+----------------------------+ +| Job Id(TaskId) | Command(Dest) | Status | Start Time | Stop Time | ++----------------+-----------------+------------+----------------------------+----------------------------+ +| 34 | "STATS" | "FINISHED" | 2021-11-01T03:32:27.000000 | 2021-11-01T03:32:27.000000 | +| 0 | "192.168.8.111" | "FINISHED" | 2021-11-01T03:32:27.000000 | 2021-11-01T03:32:41.000000 | ++----------------+-----------------+------------+----------------------------+----------------------------+ ``` |参数|说明| @@ -109,7 +108,7 @@ Queue -- running -- finished -- removed ## SHOW JOBS -`SHOW JOBS`语句列出所有未过期的作业。 +`SHOW JOBS`语句列出当前图空间内所有未过期的作业。 作业的默认过期时间为一周。如果需要修改过期时间,请修改Meta服务的参数`job_expired_secs`。详情请参见[Meta服务配置](../../5.configurations-and-logs/1.configurations/2.meta-config.md)。 @@ -117,22 +116,20 @@ Queue -- running -- finished -- removed ```ngql nebula> SHOW JOBS; -+--------+----------------------+------------+-------------------------+-------------------------+ -| Job Id | Command | Status | Start Time | Stop Time | -+--------+----------------------+------------+-------------------------+-------------------------+ -| 97 | "STATS" | "FINISHED" | 2020-11-28T14:48:52.000 | 2020-11-28T14:48:52.000 | -+--------+----------------------+------------+-------------------------+-------------------------+ -| 96 | "FLUSH" | "FINISHED" | 2020-11-28T14:14:29.000 | 2020-11-28T14:14:29.000 | -+--------+----------------------+------------+-------------------------+-------------------------+ -| 95 | "STATS" | "FINISHED" | 2020-11-28T13:02:11.000 | 2020-11-28T13:02:11.000 | -+--------+----------------------+------------+-------------------------+-------------------------+ -| 86 | "REBUILD_EDGE_INDEX" | "FINISHED" | 2020-11-26T13:38:24.000 | 2020-11-26T13:38:24.000 | -+--------+----------------------+------------+-------------------------+-------------------------+ ++--------+---------------------+------------+----------------------------+----------------------------+ +| Job Id | Command | Status | Start Time | Stop Time | ++--------+---------------------+------------+----------------------------+----------------------------+ +| 34 | "STATS" | "FINISHED" | 2021-11-01T03:32:27.000000 | 2021-11-01T03:32:27.000000 | +| 33 | "FLUSH" | "FINISHED" | 2021-11-01T03:32:15.000000 | 2021-11-01T03:32:15.000000 | +| 32 | "COMPACT" | "FINISHED" | 2021-11-01T03:32:06.000000 | 2021-11-01T03:32:06.000000 | +| 31 | "REBUILD_TAG_INDEX" | "FINISHED" | 2021-10-29T05:39:16.000000 | 2021-10-29T05:39:17.000000 | +| 10 | "COMPACT" | "FINISHED" | 2021-10-26T02:27:05.000000 | 2021-10-26T02:27:05.000000 | ++--------+---------------------+------------+----------------------------+----------------------------+ ``` ## STOP JOB -`STOP JOB`语句可以停止未完成的作业。 +`STOP JOB`语句可以停止当前图空间内未完成的作业。 ### 示例 @@ -147,7 +144,7 @@ nebula> STOP JOB 22; ## RECOVER JOB -`RECOVER JOB`语句会重新执行失败的作业,并返回已恢复的作业数量。 +`RECOVER JOB`语句会重新执行当前图空间内失败的作业,并返回已恢复的作业数量。 ### 示例 diff --git a/docs-2.0/3.ngql-guide/3.data-types/10.geography.md b/docs-2.0/3.ngql-guide/3.data-types/10.geography.md new file mode 100644 index 00000000000..f160ef4ea02 --- /dev/null +++ b/docs-2.0/3.ngql-guide/3.data-types/10.geography.md @@ -0,0 +1,76 @@ +# 地理位置 + +地理位置(GEOGRAPHY)是由经纬度构成的表示地理空间信息的数据类型。Nebula Graph当前支持[简单地理要素](https://en.wikipedia.org/wiki/Simple_Features)中的Point、LineString和Polygon三种地理形状。支持[SQL-MM 3](https://www.techrepublic.com/index.php/resource-library/whitepapers/sql-mm-spatial-the-standard-to-manage-spatial-data-in-relational-database-systems/)中的部分核心geo解析、构造、格式设置、转换、谓词和度量等函数。 + +## GEOGRAPHY + +GEOGRAPHY的基本类型是点,由经纬度确定一个点,例如`"POINT(3 8)"`表示经度为`3°`,纬度为`8°`。多个点可以构成线段或多边形。 + +|类型|示例|说明| +|:--|:--|:--| +|Point|`"POINT(3 8)"`|点类型| +|LineString|`"LINESTRING(3 8, 4.7 73.23)"`|线段类型| +|Polygon|`"POLYGON((0 1, 1 2, 2 3, 0 1))"`|多边形类型| + + + +## 示例 + +geo相关函数请参见[geo函数](../6.functions-and-expressions/14.geo.md)。 + +```ngql +//创建Tag,允许存储任意形状地理位置数据类型。 +nebula> CREATE TAG any_shape(geo geography); + +//创建Tag,只允许存储点形状地理位置数据类型。 +nebula> CREATE TAG only_point(geo geography(point)); + +//创建Tag,只允许存储线段形状地理位置数据类型。 +nebula> CREATE TAG only_linestring(geo geography(linestring)); + +//创建Tag,只允许存储多边形形状地理位置数据类型。 +nebula> CREATE TAG only_polygon(geo geography(polygon)); + +//创建Edge type,允许存储任意形状地理位置数据类型。 +nebula> CREATE EDGE any_shape_edge(geo geography); + +//创建存储多边形地理位置的点。 +nebula> INSERT VERTEX any_shape(geo) VALUES "103":(ST_GeogFromText("POLYGON((0 1, 1 2, 2 3, 0 1))")); + +//创建存储多边形地理位置的边。 +nebula> INSERT EDGE any_shape_edge(geo) VALUES "201"->"302":(ST_GeogFromText("POLYGON((0 1, 1 2, 2 3, 0 1))")); + +//查询点103的属性geo。 +nebula> FETCH PROP ON any_shape "103" YIELD ST_ASText(any_shape.geo); ++----------+---------------------------------+ +| VertexID | ST_ASText(any_shape.geo) | ++----------+---------------------------------+ +| "103" | "POLYGON((0 1, 1 2, 2 3, 0 1))" | ++----------+---------------------------------+ + +//查询边201->302的属性geo。 +nebula> FETCH PROP ON any_shape_edge "201"->"302" YIELD ST_ASText(any_shape_edge.geo); ++---------------------+---------------------+----------------------+---------------------------------+ +| any_shape_edge._src | any_shape_edge._dst | any_shape_edge._rank | ST_ASText(any_shape_edge.geo) | ++---------------------+---------------------+----------------------+---------------------------------+ +| "201" | "302" | 0 | "POLYGON((0 1, 1 2, 2 3, 0 1))" | ++---------------------+---------------------+----------------------+---------------------------------+ + +//为geo属性创建索引并使用LOOKUP查询。 +nebula> CREATE TAG INDEX any_shape_geo_index ON any_shape(geo); +nebula> REBUILD TAG INDEX any_shape_geo_index; +nebula> LOOKUP ON any_shape YIELD ST_ASText(any_shape.geo); ++----------+-------------------------------------------------+ +| VertexID | ST_ASText(any_shape.geo) | ++----------+-------------------------------------------------+ +| "103" | "POLYGON((0 1, 1 2, 2 3, 0 1))" | ++----------+-------------------------------------------------+ +``` \ No newline at end of file diff --git a/docs-2.0/3.ngql-guide/3.data-types/4.date-and-time.md b/docs-2.0/3.ngql-guide/3.data-types/4.date-and-time.md index 3a7946eeee2..bfa70748d26 100644 --- a/docs-2.0/3.ngql-guide/3.data-types/4.date-and-time.md +++ b/docs-2.0/3.ngql-guide/3.data-types/4.date-and-time.md @@ -18,7 +18,7 @@ - 不支持函数`localdatetime()`和`duration()`。 -- 不支持大部分字符串时间格式,仅支持`YYYY-MM-DDThh:mm:ss`。 +- 不支持大部分字符串时间格式,支持`YYYY-MM-DDThh:mm:ss`和`YYYY-MM-DD hh:mm:ss`。 ## DATE @@ -54,7 +54,7 @@ ```ngql # 传入当前时间。 - nebula> return timestamp(); + nebula> RETURN timestamp(); +-------------+ | timestamp() | +-------------+ @@ -62,7 +62,7 @@ +-------------+ # 传入指定时间。 - nebula> return timestamp("2021-07-05T06:18:43.984000"); + nebula> RETURN timestamp("2021-07-05T06:18:43.984000"); +-----------------------------------------+ | timestamp("2021-07-05T06:18:43.984000") | +-----------------------------------------+ @@ -128,16 +128,16 @@ 还可以使用`WITH`语句设置具体日期和时间,例如: ```ngql -nebula> WITH time({hour: 12, minute: 31, second: 14}) AS d RETURN d; +nebula> WITH time({hour: 12, minute: 31, second: 14, millisecond:111, microsecond: 222}) AS d RETURN d; +-----------------+ | d | +-----------------+ -| 12:31:14.000000 | +| 12:31:14.111222 | +-----------------+ nebula> WITH date({year: 1984, month: 10, day: 11}) AS x RETURN x + 1; +------------+ -| x | +| (x+1) | +------------+ | 1984-10-12 | +------------+ 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 314dfc2dae8..2c3a5c439e7 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,7 +77,7 @@ nebula> INSERT VERTEX player(name) VALUES "Kobe":("Kobe"); 查询点`Kobe`,属性`age`为默认值`18`。 ```ngql -nebula> FETCH PROP ON player "Kobe" +nebula> FETCH PROP ON player "Kobe"; +-----------------------------------------+ | vertices_ | +-----------------------------------------+ diff --git a/docs-2.0/3.ngql-guide/3.data-types/6.list.md b/docs-2.0/3.ngql-guide/3.data-types/6.list.md index 47dbdd7f594..6cabe886397 100644 --- a/docs-2.0/3.ngql-guide/3.data-types/6.list.md +++ b/docs-2.0/3.ngql-guide/3.data-types/6.list.md @@ -180,13 +180,12 @@ nebula> RETURN size([1,2,3]); +---------------+ # 将列表[92,90]中的元素做运算,然后在where子句中进行条件判断。 -nebula> GO FROM "player100" OVER follow WHERE follow.degree NOT IN [x IN [92, 90] | x + $$.player.age] \ - YIELD follow._dst AS id, follow.degree AS degree; +nebula> GO FROM "player100" OVER follow WHERE properties(edge).degree NOT IN [x IN [92, 90] | x + $$.player.age] \ + YIELD dst(edge) AS id, properties(edge).degree AS degree; +-------------+--------+ | id | degree | +-------------+--------+ | "player101" | 95 | -+-------------+--------+ | "player102" | 90 | +-------------+--------+ @@ -197,7 +196,6 @@ nebula> MATCH p = (n:player{name:"Tim Duncan"})-[:follow]->(m) \ | r | +------------+ | [142, 136] | -+------------+ | [142, 133] | +------------+ ``` diff --git a/docs-2.0/3.ngql-guide/3.data-types/8.map.md b/docs-2.0/3.ngql-guide/3.data-types/8.map.md index 997dc81c859..59809394691 100644 --- a/docs-2.0/3.ngql-guide/3.data-types/8.map.md +++ b/docs-2.0/3.ngql-guide/3.data-types/8.map.md @@ -5,7 +5,7 @@ ## 字面值映射 ```ngql -nebula> YIELD {key: 'Value', listKey: [{inner: 'Map1'}, {inner: 'Map2'}]} +nebula> YIELD {key: 'Value', listKey: [{inner: 'Map1'}, {inner: 'Map2'}]}; +-------------------------------------------------------------+ | {key:Value,listKey:[{inner:Map1},{inner:Map2}]} | +-------------------------------------------------------------+ diff --git a/docs-2.0/3.ngql-guide/3.data-types/9.type-conversion.md b/docs-2.0/3.ngql-guide/3.data-types/9.type-conversion.md index 841b36434be..a2cede0536d 100644 --- a/docs-2.0/3.ngql-guide/3.data-types/9.type-conversion.md +++ b/docs-2.0/3.ngql-guide/3.data-types/9.type-conversion.md @@ -20,7 +20,8 @@ nGQL 2.0使用OpenCypher的方式进行类型强制转换。 ## 示例 ```ngql -nebula> UNWIND [true, false, 'true', 'false', NULL] AS b RETURN toBoolean(b) AS b; +nebula> UNWIND [true, false, 'true', 'false', NULL] AS b \ + RETURN toBoolean(b) AS b; +----------+ | b | +----------+ @@ -49,7 +50,8 @@ nebula> RETURN toInteger(1), toInteger('1'), toInteger('1e3'), toInteger('not a | 1 | 1 | 1000 | __NULL__ | +--------------+----------------+------------------+---------------------------+ -nebula> MATCH (a:player)-[e]-() RETURN type(e); +nebula> MATCH (a:player)-[e]-() \ + RETURN type(e); +----------+ | type(e) | +----------+ @@ -57,14 +59,18 @@ nebula> MATCH (a:player)-[e]-() RETURN type(e); +----------+ | "follow" | -nebula> MATCH (a:player {name: "Tim Duncan"}) WHERE toInteger(id(a)) == 100 RETURN a; -+----------------------------------------------+ -| a | -+----------------------------------------------+ -| ("100" :player{age: 42, name: "Tim Duncan"}) | -+----------------------------------------------+ +nebula> MATCH (a:player {name: "Tim Duncan"}) \ + WHERE toInteger(right(id(a),3)) == 100 \ + RETURN a; ++----------------------------------------------------+ +| a | ++----------------------------------------------------+ +| ("player100" :player{age: 42, name: "Tim Duncan"}) | ++----------------------------------------------------+ -nebula> MATCH (n:player) WITH n LIMIT toInteger(ceil(1.8)) RETURN count(*) AS count; +nebula> MATCH (n:player) \ + WITH n LIMIT toInteger(ceil(1.8)) \ + RETURN count(*) AS count; +-------+ | count | +-------+ diff --git a/docs-2.0/3.ngql-guide/4.variable-and-composite-queries/1.composite-queries.md b/docs-2.0/3.ngql-guide/4.variable-and-composite-queries/1.composite-queries.md index dcc012cb224..f59ccb03fb3 100644 --- a/docs-2.0/3.ngql-guide/4.variable-and-composite-queries/1.composite-queries.md +++ b/docs-2.0/3.ngql-guide/4.variable-and-composite-queries/1.composite-queries.md @@ -59,12 +59,14 @@ Nebula Graph支持三种方式进行复合查询(或子查询): ```ngql # 管道符连接多个查询。 - nebula> GO FROM "player100" OVER follow YIELD follow._dst AS id | \ - GO FROM $-.id OVER serve YIELD $$.team.name AS Team, \ - $^.player.name AS Player; - +---------+-------------+ - | Team | Player | - +---------+-------------+ - | Nuggets | Tony Parker | - +---------+-------------+ + nebula> GO FROM "player100" OVER follow YIELD dst(edge) AS id | \ + GO FROM $-.id OVER serve YIELD properties($$).name AS Team, \ + properties($^).name AS Player; + +-----------+-----------------+ + | Team | Player | + +-----------+-----------------+ + | "Spurs" | "Tony Parker" | + | "Hornets" | "Tony Parker" | + | "Spurs" | "Manu Ginobili" | + +-----------+-----------------+ ``` diff --git a/docs-2.0/3.ngql-guide/4.variable-and-composite-queries/2.user-defined-variables.md b/docs-2.0/3.ngql-guide/4.variable-and-composite-queries/2.user-defined-variables.md index bbc8f616851..e18396f1513 100644 --- a/docs-2.0/3.ngql-guide/4.variable-and-composite-queries/2.user-defined-variables.md +++ b/docs-2.0/3.ngql-guide/4.variable-and-composite-queries/2.user-defined-variables.md @@ -32,12 +32,14 @@ nebula> MATCH (v:player{name:"Tim Duncan"}) RETURN v; ## 示例 ```ngql -nebula> $var = GO FROM "player100" OVER follow YIELD follow._dst AS id; \ - GO FROM $var.id OVER serve YIELD $$.team.name AS Team, \ - $^.player.name AS Player; -+---------+-------------+ -| Team | Player | -+---------+-------------+ -| Nuggets | Tony Parker | -+---------+-------------+ +nebula> $var = GO FROM "player100" OVER follow YIELD dst(edge) AS id; \ + GO FROM $var.id OVER serve YIELD properties($$).name AS Team, \ + properties($^).name AS Player; ++-----------+-----------------+ +| Team | Player | ++-----------+-----------------+ +| "Spurs" | "Tony Parker" | +| "Hornets" | "Tony Parker" | +| "Spurs" | "Manu Ginobili" | ++-----------+-----------------+ ``` diff --git a/docs-2.0/3.ngql-guide/4.variable-and-composite-queries/3.property-reference.md b/docs-2.0/3.ngql-guide/4.variable-and-composite-queries/3.property-reference.md index 33a82c0bca7..61b86a20149 100644 --- a/docs-2.0/3.ngql-guide/4.variable-and-composite-queries/3.property-reference.md +++ b/docs-2.0/3.ngql-guide/4.variable-and-composite-queries/3.property-reference.md @@ -65,9 +65,9 @@ nebula> GO FROM "player100" OVER follow YIELD $^.player.name AS startName, $$.pl | startName | endAge | +--------------+--------+ | "Tim Duncan" | 36 | +| "Tim Duncan" | 41 | +--------------+--------+ -| "Tim Duncan" | 33 | -+--------------+--------+ + # 返回Edge type follow的degree属性值。 nebula> GO FROM "player100" OVER follow YIELD follow.degree; @@ -75,8 +75,7 @@ nebula> GO FROM "player100" OVER follow YIELD follow.degree; | follow.degree | +---------------+ | 95 | -+---------------+ -| 90 | +| 95 | +---------------+ # 返回EdgeType 是 follow 的起始点 VID、目的点 VID、EdgeType 编码(正数为正向边,负数为逆向边),和边的 rank 值。 @@ -84,8 +83,19 @@ nebula> GO FROM "player100" OVER follow YIELD follow._src, follow._dst, follow._ +-------------+-------------+--------------+--------------+ | follow._src | follow._dst | follow._type | follow._rank | +-------------+-------------+--------------+--------------+ -| "player100" | "player101" | 136 | 0 | -+-------------+-------------+--------------+--------------+ -| "player100" | "player102" | 136 | 0 | +| "player100" | "player101" | 17 | 0 | +| "player100" | "player125" | 17 | 0 | +-------------+-------------+--------------+--------------+ ``` + +!!! compatibility "历史版本兼容性" + + Nebula Graph 2.6.0起支持了新的[Schema函数](../6.functions-and-expressions/4.schema.md),以上示例中的语句在2.6.0版本中的写法如下。 + + ```ngql + GO FROM "player100" OVER follow YIELD properties($^).name AS startName, properties($$).age AS endAge; + GO FROM "player100" OVER follow YIELD properties(edge).degree; + GO FROM "player100" OVER follow YIELD src(edge), dst(edge), type(edge), rank(edge); + ``` + + 在2.6.0版本中Nebula Graph依然兼容旧语法。 diff --git a/docs-2.0/3.ngql-guide/5.operators/1.comparison.md b/docs-2.0/3.ngql-guide/5.operators/1.comparison.md index d58772f4447..7b4f06c6743 100644 --- a/docs-2.0/3.ngql-guide/5.operators/1.comparison.md +++ b/docs-2.0/3.ngql-guide/5.operators/1.comparison.md @@ -118,11 +118,11 @@ nebula> YIELD 0.11 <= 0.11; ```ngql nebula> YIELD 1 != '1'; -+--------+ -| (1!=1) | -+--------+ -| true | -+--------+ ++----------+ +| (1!="1") | ++----------+ +| true | ++----------+ ``` ### `IS [NOT] NULL` @@ -165,9 +165,7 @@ nebula> MATCH (n:player) \ | n.age IS NULL | n.name IS NOT NULL | n.empty IS NULL | +---------------+--------------------+-----------------+ | false | true | true | -+---------------+--------------------+-----------------+ | false | true | true | -+---------------+--------------------+-----------------+ | false | true | true | +---------------+--------------------+-----------------+ ... @@ -190,13 +188,12 @@ nebula> RETURN "a" IS NOT EMPTY; | true | +------------------+ -nebula> GO FROM "player100" OVER * WHERE $$.player.name IS NOT EMPTY YIELD follow._dst; -+-------------+ -| follow._dst | +nebula> GO FROM "player100" OVER * WHERE properties($$).name IS NOT EMPTY YIELD dst(edge); +-------------+ -| "player125" | +| dst(EDGE) | +-------------+ +| "team204" | | "player101" | +| "player125" | +-------------+ - ``` 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 f8dd5e861f2..6dfdbe39e07 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 @@ -18,13 +18,16 @@ nGQL和SQL之间的一个主要区别是子查询的组成方式。 ```ngql nebula> GO FROM "player100" OVER follow \ - YIELD follow._dst AS dstid, $$.player.name AS Name | \ + YIELD dst(edge) AS dstid, properties($$).name AS Name | \ GO FROM $-.dstid OVER follow; +-------------+ | follow._dst | +-------------+ -| "player101" | +| "player100" | +| "player102" | +| "player125" | +| "player100" | +-------------+ ``` @@ -34,7 +37,7 @@ nebula> GO FROM "player100" OVER follow \ ## 性能提示 -Nebula Graph {{ nebula.release }} 中的管道对性能有影响,以`A | B`为例,体现在以下几个方面: +Nebula Graph 中的管道对性能有影响,以`A | B`为例,体现在以下几个方面: 1. 管道是同步操作。也即需要管道之前的子句`A`执行完毕后,数据才能整体进入管道子句。 @@ -50,4 +53,4 @@ Nebula Graph {{ nebula.release }} 中的管道对性能有影响,以`A | B`为 4. 每个 graphd 执行部分 B。 - 这样通常比单个graphd 执行完整地`A | B`要快很多。 + 这样通常比单个 graphd 执行完整地`A | B`要快很多。 diff --git a/docs-2.0/3.ngql-guide/5.operators/5.property-reference.md b/docs-2.0/3.ngql-guide/5.operators/5.property-reference.md index f5c75eedc6b..f2873b34e21 100644 --- a/docs-2.0/3.ngql-guide/5.operators/5.property-reference.md +++ b/docs-2.0/3.ngql-guide/5.operators/5.property-reference.md @@ -18,27 +18,24 @@ nGQL提供引用符来表示`WHERE`和`YIELD`子句中的属性,或者复合 ```ngql # 返回起始点和目的点的年龄。 -nebula> GO FROM "player100" OVER follow YIELD $^.player.age AS SrcAge, $$.player.age AS DestAge; +nebula> GO FROM "player100" OVER follow YIELD properties($^).age AS SrcAge, properties($$).age AS DestAge; +--------+---------+ | SrcAge | DestAge | +--------+---------+ | 42 | 36 | -+--------+---------+ | 42 | 41 | +--------+---------+ # 返回player100追随的player的名称和团队。 nebula> GO FROM "player100" OVER follow \ - YIELD follow._dst AS id | \ + YIELD dst(edge) AS id | \ GO FROM $-.id OVER serve \ - YIELD $^.player.name AS Player, $$.team.name AS Team; + YIELD properties($^).name AS Player, properties($$).name AS Team; +-----------------+-----------+ | Player | Team | +-----------------+-----------+ | "Tony Parker" | "Spurs" | -+-----------------+-----------+ | "Tony Parker" | "Hornets" | -+-----------------+-----------+ | "Manu Ginobili" | "Spurs" | +-----------------+-----------+ ``` 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 eab11027745..bd774948d47 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 @@ -30,9 +30,9 @@ nebula> GO FROM "player102" OVER follow \ +-------------+ | follow._dst | +-------------+ +| "player100" | | "player101" | -+-------------+ -| "player102" | +| "player125" | +-------------+ # 返回两个查询结果的并集,包含重复的元素。 @@ -42,27 +42,25 @@ nebula> GO FROM "player102" OVER follow \ +-------------+ | follow._dst | +-------------+ +| "player100" | | "player101" | -+-------------+ | "player101" | -+-------------+ -| "player102" | +| "player125" | +-------------+ # UNION也可以和YIELD语句一起使用,去重时会检查每一行的所有列,每列都相同时才会去重。 nebula> GO FROM "player102" OVER follow \ - YIELD follow._dst AS id, follow.degree AS Degree, $$.player.age AS Age \ + YIELD dst(edge) AS id, properties(edge).degree AS Degree, properties($$).age AS Age \ UNION /* DISTINCT */ \ GO FROM "player100" OVER follow \ - YIELD follow._dst AS id, follow.degree AS Degree, $$.player.age AS Age; + YIELD dst(edge) AS id, properties(edge).degree AS Degree, properties($$).age AS Age; +-------------+--------+-----+ | id | Degree | Age | +-------------+--------+-----+ -| "player101" | 75 | 36 | -+-------------+--------+-----+ -| "player101" | 96 | 36 | -+-------------+--------+-----+ -| "player102" | 90 | 33 | +| "player100" | 75 | 42 | +| "player101" | 75 | 36 | +| "player101" | 95 | 36 | +| "player125" | 95 | 41 | +-------------+--------+-----+ ``` @@ -80,11 +78,14 @@ nebula> GO FROM "player102" OVER follow \ ```ngql nebula> GO FROM "player102" OVER follow \ - YIELD follow._dst AS id, follow.degree AS Degree, $$.player.age AS Age \ + YIELD dst(edge) AS id, properties(edge).degree AS Degree, properties($$).age AS Age \ INTERSECT \ GO FROM "player100" OVER follow \ - YIELD follow._dst AS id, follow.degree AS Degree, $$.player.age AS Age; -Empty set (time spent 2990/3511 us) + YIELD dst(edge) AS id, properties(edge).degree AS Degree, properties($$).age AS Age; ++----+--------+-----+ +| id | Degree | Age | ++----+--------+-----+ ++----+--------+-----+ ``` ## MINUS @@ -104,13 +105,17 @@ nebula> GO FROM "player100" OVER follow \ +-------------+ | follow._dst | +-------------+ -| "player102" | +| "player125" | +-------------+ nebula> GO FROM "player102" OVER follow \ MINUS \ GO FROM "player100" OVER follow; -Empty set (time spent 2243/3259 us) ++-------------+ +| follow._dst | ++-------------+ +| "player100" | ++-------------+ ``` ## 集合运算符和管道符的优先级 @@ -121,18 +126,19 @@ Empty set (time spent 2243/3259 us) ```ngql nebula> GO FROM "player102" OVER follow \ - YIELD follow._dst AS play_dst \ + YIELD dst(edge) AS play_dst \ UNION \ GO FROM "team200" OVER serve REVERSELY \ - YIELD serve._dst AS play_dst \ - | GO FROM $-.play_dst OVER follow YIELD follow._dst AS play_dst; + YIELD src(edge) AS play_src \ + | GO FROM $-.play_src OVER follow YIELD dst(edge) AS play_dst; +-------------+ | play_dst | +-------------+ +| "player100" | | "player101" | -+-------------+ -| "player102" | +| "player117" | +| "player105" | +-------------+ ``` @@ -144,11 +150,11 @@ nebula> GO FROM "player102" OVER follow \ ```ngql nebula> (GO FROM "player102" OVER follow \ - YIELD follow._dst AS play_dst \ + YIELD dst(edge) AS play_dst \ UNION \ GO FROM "team200" OVER serve REVERSELY \ - YIELD serve._dst AS play_dst) \ - | GO FROM $-.play_dst OVER follow YIELD follow._dst AS play_dst; + YIELD src(edge) AS play_dst) \ + | GO FROM $-.play_dst OVER follow YIELD dst(edge) AS play_dst; ``` 该查询中,圆括号包裹的部分先执行,即先执行`UNION`操作,再将结果结合管道符进行下一步操作。 diff --git a/docs-2.0/3.ngql-guide/5.operators/7.string.md b/docs-2.0/3.ngql-guide/5.operators/7.string.md index 51696302cd3..f749e56b1d7 100644 --- a/docs-2.0/3.ngql-guide/5.operators/7.string.md +++ b/docs-2.0/3.ngql-guide/5.operators/7.string.md @@ -21,11 +21,11 @@ Nebula Graph支持使用字符串运算符进行连接、搜索、匹配运算 ```ngql nebula> RETURN 'a' + 'b'; -+-------+ -| (a+b) | -+-------+ -| "ab" | -+-------+ ++-----------+ +| ("a"+"b") | ++-----------+ +| "ab" | ++-----------+ nebula> UNWIND 'a' AS a UNWIND 'b' AS b RETURN a + b; +-------+ | (a+b) | @@ -47,28 +47,28 @@ nebula> MATCH (s:player)-[e:serve]->(t:team) WHERE id(s) == "player101" \ | "Tony Parker" | 2018 | 2019 | "Hornets" | +---------------+--------------+------------+-----------+ -nebula> GO FROM "player101" OVER serve WHERE (STRING)serve.start_year CONTAINS "19" AND \ - $^.player.name CONTAINS "ny" \ - YIELD $^.player.name, serve.start_year, serve.end_year, $$.team.name; -+----------------+------------------+----------------+--------------+ -| $^.player.name | serve.start_year | serve.end_year | $$.team.name | -+----------------+------------------+----------------+--------------+ -| "Tony Parker" | 1999 | 2018 | "Spurs" | -+----------------+------------------+----------------+--------------+ - -nebula> GO FROM "player101" OVER serve WHERE !($$.team.name CONTAINS "ets") \ - YIELD $^.player.name, serve.start_year, serve.end_year, $$.team.name; -+----------------+------------------+----------------+--------------+ -| $^.player.name | serve.start_year | serve.end_year | $$.team.name | -+----------------+------------------+----------------+--------------+ -| "Tony Parker" | 1999 | 2018 | "Spurs" | -+----------------+------------------+----------------+--------------+ +nebula> GO FROM "player101" OVER serve WHERE (STRING)properties(edge).start_year CONTAINS "19" AND \ + properties($^).name CONTAINS "ny" \ + YIELD properties($^).name, properties(edge).start_year, properties(edge).end_year, properties($$).name; ++---------------------+-----------------------------+---------------------------+---------------------+ +| properties($^).name | properties(EDGE).start_year | properties(EDGE).end_year | properties($$).name | ++---------------------+-----------------------------+---------------------------+---------------------+ +| "Tony Parker" | 1999 | 2018 | "Spurs" | ++---------------------+-----------------------------+---------------------------+---------------------+ + +nebula> GO FROM "player101" OVER serve WHERE !(properties($$).name CONTAINS "ets") \ + YIELD properties($^).name, properties(edge).start_year, properties(edge).end_year, properties($$).name; ++---------------------+-----------------------------+---------------------------+---------------------+ +| properties($^).name | properties(EDGE).start_year | properties(EDGE).end_year | properties($$).name | ++---------------------+-----------------------------+---------------------------+---------------------+ +| "Tony Parker" | 1999 | 2018 | "Spurs" | ++---------------------+-----------------------------+---------------------------+---------------------+ ``` ### `(NOT) IN` ```ngql -nebula> RETURN 1 IN [1,2,3], "Yao" NOT IN ["Yi", "Tim", "Kobe"], NULL IN ["Yi", "Tim", "Kobe"] +nebula> RETURN 1 IN [1,2,3], "Yao" NOT IN ["Yi", "Tim", "Kobe"], NULL IN ["Yi", "Tim", "Kobe"]; +----------------+------------------------------------+-------------------------------+ | (1 IN [1,2,3]) | ("Yao" NOT IN ["Yi","Tim","Kobe"]) | (NULL IN ["Yi","Tim","Kobe"]) | +----------------+------------------------------------+-------------------------------+ @@ -79,14 +79,14 @@ nebula> RETURN 1 IN [1,2,3], "Yao" NOT IN ["Yi", "Tim", "Kobe"], NULL IN ["Yi", ### `(NOT) STARTS WITH` ```ngql -nebula> RETURN 'apple' STARTS WITH 'app', 'apple' STARTS WITH 'a', 'apple' STARTS WITH toUpper('a') +nebula> RETURN 'apple' STARTS WITH 'app', 'apple' STARTS WITH 'a', 'apple' STARTS WITH toUpper('a'); +-----------------------------+---------------------------+------------------------------------+ | ("apple" STARTS WITH "app") | ("apple" STARTS WITH "a") | ("apple" STARTS WITH toUpper("a")) | +-----------------------------+---------------------------+------------------------------------+ | true | true | false | +-----------------------------+---------------------------+------------------------------------+ -nebula> RETURN 'apple' STARTS WITH 'b','apple' NOT STARTS WITH 'app' +nebula> RETURN 'apple' STARTS WITH 'b','apple' NOT STARTS WITH 'app'; +---------------------------+---------------------------------+ | ("apple" STARTS WITH "b") | ("apple" NOT STARTS WITH "app") | +---------------------------+---------------------------------+ @@ -97,7 +97,7 @@ nebula> RETURN 'apple' STARTS WITH 'b','apple' NOT STARTS WITH 'app' ### `(NOT) ENDS WITH` ```ngql -nebula> RETURN 'apple' ENDS WITH 'app', 'apple' ENDS WITH 'e', 'apple' ENDS WITH 'E', 'apple' ENDS WITH 'b' +nebula> RETURN 'apple' ENDS WITH 'app', 'apple' ENDS WITH 'e', 'apple' ENDS WITH 'E', 'apple' ENDS WITH 'b'; +---------------------------+-------------------------+-------------------------+-------------------------+ | ("apple" ENDS WITH "app") | ("apple" ENDS WITH "e") | ("apple" ENDS WITH "E") | ("apple" ENDS WITH "b") | +---------------------------+-------------------------+-------------------------+-------------------------+ @@ -115,11 +115,11 @@ Nebula Graph支持使用正则表达式进行过滤,正则表达式的语法 ```ngql nebula> RETURN "384748.39" =~ "\\d+(\\.\\d{2})?"; -+----------------------------+ -| (384748.39=~\d+(\.\d{2})?) | -+----------------------------+ -| true | -+----------------------------+ ++--------------------------------+ +| ("384748.39"=~"\d+(\.\d{2})?") | ++--------------------------------+ +| true | ++--------------------------------+ nebula> MATCH (v:player) WHERE v.name =~ 'Tony.*' RETURN v.name; +---------------+ diff --git a/docs-2.0/3.ngql-guide/5.operators/8.list.md b/docs-2.0/3.ngql-guide/5.operators/8.list.md index 98ae11abbc0..9ed38bce4f2 100644 --- a/docs-2.0/3.ngql-guide/5.operators/8.list.md +++ b/docs-2.0/3.ngql-guide/5.operators/8.list.md @@ -41,7 +41,6 @@ nebula> WITH [2, 3, 4, 5] AS numberlist \ | number | +--------+ | 2 | -+--------+ | 3 | +--------+ diff --git a/docs-2.0/3.ngql-guide/6.functions-and-expressions/1.math.md b/docs-2.0/3.ngql-guide/6.functions-and-expressions/1.math.md index aea116c3d72..3ee3fcffc69 100644 --- a/docs-2.0/3.ngql-guide/6.functions-and-expressions/1.math.md +++ b/docs-2.0/3.ngql-guide/6.functions-and-expressions/1.math.md @@ -53,18 +53,17 @@ Nebula Graph支持以下内置数学函数。 ```ngql # 支持聚合函数 -nebula> GO FROM "Tim Duncan" OVER like YIELD like._dst AS dst, $$.player.age AS age \ +nebula> GO FROM "player100" OVER follow YIELD dst(edge) AS dst, properties($$).age AS age \ | GROUP BY $-.dst \ YIELD \ $-.dst AS dst, \ toInteger((sum($-.age)/count($-.age)))+avg(distinct $-.age+1)+1 AS statistics; -+-----------------+------------+ -| dst | statistics | -+-----------------+------------+ -| "Tony Parker" | 74.0 | -+-----------------+------------+ -| "Manu Ginobili" | 84.0 | -+-----------------+------------+ ++-------------+------------+ +| dst | statistics | ++-------------+------------+ +| "player125" | 84.0 | +| "player101" | 74.0 | ++-------------+------------+ Got 2 rows (time spent 4739/5064 us) ``` diff --git a/docs-2.0/3.ngql-guide/6.functions-and-expressions/10.collect.md b/docs-2.0/3.ngql-guide/6.functions-and-expressions/10.collect.md index 5b46716c2da..47d308105cf 100644 --- a/docs-2.0/3.ngql-guide/6.functions-and-expressions/10.collect.md +++ b/docs-2.0/3.ngql-guide/6.functions-and-expressions/10.collect.md @@ -13,9 +13,7 @@ nebula> UNWIND [1, 2, 1] AS a \ | a | +---+ | 1 | -+---+ | 2 | -+---+ | 1 | +---+ @@ -33,7 +31,6 @@ nebula> UNWIND [1, 2, 1] AS a \ | a | collect(a) | size(COLLECT(a)) | +---+------------+------------------+ | 2 | [2] | 1 | -+---+------------+------------------+ | 1 | [1, 1] | 2 | +---+------------+------------------+ @@ -62,7 +59,7 @@ nebula> MATCH (n:player) \ RETURN collect(n.age); +---------------------------------------------------------------+ | collect(n.age) | -----------------------------------------------------------------+ ++---------------------------------------------------------------+ | [32, 32, 34, 29, 41, 40, 33, 25, 40, 37, ... ... @@ -73,10 +70,8 @@ nebula> MATCH (n:player) \ | age | collect(n.name) | +-----+--------------------------------------------------------------------------+ | 24 | ["Giannis Antetokounmpo"] | -+-----+--------------------------------------------------------------------------+ | 20 | ["Luka Doncic"] | -+-----+--------------------------------------------------------------------------+ | 25 | ["Joel Embiid", "Kyle Anderson"] | +-----+--------------------------------------------------------------------------+ ... -``` \ No newline at end of file +``` 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 6c2e22e3307..0144776308b 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 @@ -48,29 +48,22 @@ nebula> MATCH p = (n:player{name:"LeBron James"})<-[:follow]-(m) \ | src1 | dst2 | sum | +------+------+-----+ | 34 | 31 | 165 | -+------+------+-----+ | 34 | 29 | 163 | -+------+------+-----+ | 34 | 33 | 167 | -+------+------+-----+ | 34 | 26 | 160 | -+------+------+-----+ | 34 | 34 | 168 | -+------+------+-----+ | 34 | 37 | 171 | +------+------+-----+ nebula> LOOKUP ON player WHERE player.name == "Tony Parker" \ | GO FROM $-.VertexID over follow \ - WHERE follow.degree != reduce(totalNum = 5, n IN range(1, 3) | $$.player.age + totalNum + n) \ - YIELD $$.player.name AS id, $$.player.age AS age, follow.degree AS degree; + 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; +---------------------+-----+--------+ | id | age | degree | +---------------------+-----+--------+ | "Tim Duncan" | 42 | 95 | -+---------------------+-----+--------+ | "LaMarcus Aldridge" | 33 | 90 | -+---------------------+-----+--------+ | "Manu Ginobili" | 41 | 95 | +---------------------+-----+--------+ ``` diff --git a/docs-2.0/3.ngql-guide/6.functions-and-expressions/12.hash.md b/docs-2.0/3.ngql-guide/6.functions-and-expressions/12.hash.md index 052295d29b1..662a012294a 100644 --- a/docs-2.0/3.ngql-guide/6.functions-and-expressions/12.hash.md +++ b/docs-2.0/3.ngql-guide/6.functions-and-expressions/12.hash.md @@ -31,7 +31,7 @@ nebula> YIELD hash(-123); ```ngql nebula> YIELD hash("to_be_hashed"); +----------------------+ -| hash(to_be_hashed) | +| hash("to_be_hashed") | +----------------------+ | -1098333533029391540 | +----------------------+ diff --git a/docs-2.0/3.ngql-guide/6.functions-and-expressions/13.concat.md b/docs-2.0/3.ngql-guide/6.functions-and-expressions/13.concat.md index 95bb47aa63e..6cbb698b4f6 100644 --- a/docs-2.0/3.ngql-guide/6.functions-and-expressions/13.concat.md +++ b/docs-2.0/3.ngql-guide/6.functions-and-expressions/13.concat.md @@ -33,12 +33,11 @@ nebula> RETURN concat("1","2",NULL) AS r; +----------+ nebula> GO FROM "player100" over follow \ - YIELD concat(follow._src, $^.player.age, $$.player.name, follow.degree) AS A; + YIELD concat(src(edge), properties($^).age, properties($$).name, properties(edge).degree) AS A; +------------------------------+ | A | +------------------------------+ | "player10042Tony Parker95" | -+------------------------------+ | "player10042Manu Ginobili95" | +------------------------------+ ``` @@ -92,12 +91,11 @@ nebula> RETURN concat_ws("+","a") AS r; +-----+ nebula> GO FROM "player100" over follow \ - YIELD concat_ws(" ",follow._src, $^.player.age, $$.player.name, follow.degree) AS A; + YIELD concat_ws(" ",src(edge), properties($^).age, properties($$).name, properties(edge).degree) AS A; +---------------------------------+ | A | +---------------------------------+ | "player100 42 Tony Parker 95" | -+---------------------------------+ | "player100 42 Manu Ginobili 95" | +---------------------------------+ ``` diff --git a/docs-2.0/3.ngql-guide/6.functions-and-expressions/14.geo.md b/docs-2.0/3.ngql-guide/6.functions-and-expressions/14.geo.md new file mode 100644 index 00000000000..f3934f67f26 --- /dev/null +++ b/docs-2.0/3.ngql-guide/6.functions-and-expressions/14.geo.md @@ -0,0 +1,103 @@ +# geo函数 + +geo函数用于生成地理位置(GEOGRAPHY)数据类型的值或对其执行操作。 + +关于地理位置数据类型说明请参见[地理位置](../3.data-types/10.geography.md)。 + +## 函数说明 + +| 函数 | 返回类型 | 说明 | +| :---- | ----- | :---- | +| ST_Point(longitude, latitude) | `GEOGRAPHY` | 创建包含一个点的地理位置。 | +| ST_GeogFromText(wkt_string) | `GEOGRAPHY` | 返回与传入的WKT字符串形式相对应的GEOGRAPHY。 | +| ST_ASText(geography) | `STRING` | 返回传入的GEOGRAPHY的WKT字符串形式。 | +| ST_Centroid(geography) | `GEOGRAPHY` | 以单点GEOGRAPHY的形式返回传入的GEOGRAPHY的形心。 | +| ST_ISValid(geography) | `BOOL` | 返回传入的GEOGRAPHY是否有效。 | +| ST_Intersects(geography_1, geography_2) | `BOOL` | 返回传入的两个GEOGRAPHY是否有交集。 | +| ST_Covers(geography_1, geography_2) | `BOOL` | 返回geography_1是否完全包含geography_2。如果geography_2中没有位于geography_1外部的点,返回True。 | +| ST_CoveredBy(geography_1, geography_2) | `BOOL` | 返回geography_2是否完全包含geography_1。如果geography_1中没有位于geography_2外部的点,返回True。 | +| ST_DWithin(geography_1, geography_2, distance) | `BOOL` | 如果geography_1中至少有一个点与geography_2中的一个点的距离小于或等于distance参数(以米为单位)指定的距离,则返回True。 | +| ST_Distance(geography_1, geography_2) | `FLOAT` | 返回两个非空GEOGRAPHY之间的最短距离(以米为单位)。 | +| S2_CellIdFromPoint(point_geography) | `INT` | 返回覆盖点GEOGRAPHY的[S2单元](https://s2geometry.io/devguide/s2cell_hierarchy)ID。 | +| S2_CoveringCellIds(geography) | `ARRAY` | 返回覆盖传入的GEOGRAPHY的S2单元ID的数组。 | + +## 示例 + +```ngql +nebula> RETURN ST_ASText(ST_Point(1,1)); ++--------------------------+ +| ST_ASText(ST_Point(1,1)) | ++--------------------------+ +| "POINT(1 1)" | ++--------------------------+ + +nebula> RETURN ST_ASText(ST_GeogFromText("POINT(3 8)")); ++------------------------------------------+ +| ST_ASText(ST_GeogFromText("POINT(3 8)")) | ++------------------------------------------+ +| "POINT(3 8)" | ++------------------------------------------+ + +nebula> RETURN ST_ASTEXT(ST_Centroid(ST_GeogFromText("LineString(0 1,1 0)"))); ++----------------------------------------------------------------+ +| ST_ASTEXT(ST_Centroid(ST_GeogFromText("LineString(0 1,1 0)"))) | ++----------------------------------------------------------------+ +| "POINT(0.5000380800773782 0.5000190382261059)" | ++----------------------------------------------------------------+ + +nebula> RETURN ST_ISValid(ST_GeogFromText("POINT(3 8)")); ++-------------------------------------------+ +| ST_ISValid(ST_GeogFromText("POINT(3 8)")) | ++-------------------------------------------+ +| true | ++-------------------------------------------+ + +nebula> RETURN ST_Intersects(ST_GeogFromText("LineString(0 1,1 0)"),ST_GeogFromText("LineString(0 0,1 1)")); ++----------------------------------------------------------------------------------------------+ +| ST_Intersects(ST_GeogFromText("LineString(0 1,1 0)"),ST_GeogFromText("LineString(0 0,1 1)")) | ++----------------------------------------------------------------------------------------------+ +| true | ++----------------------------------------------------------------------------------------------+ + +nebula> RETURN ST_Covers(ST_GeogFromText("POLYGON((0 0,10 0,10 10,0 10,0 0))"),ST_Point(1,2)); ++--------------------------------------------------------------------------------+ +| ST_Covers(ST_GeogFromText("POLYGON((0 0,10 0,10 10,0 10,0 0))"),ST_Point(1,2)) | ++--------------------------------------------------------------------------------+ +| true | ++--------------------------------------------------------------------------------+ + +nebula> RETURN ST_CoveredBy(ST_Point(1,2),ST_GeogFromText("POLYGON((0 0,10 0,10 10,0 10,0 0))")); ++-----------------------------------------------------------------------------------+ +| ST_CoveredBy(ST_Point(1,2),ST_GeogFromText("POLYGON((0 0,10 0,10 10,0 10,0 0))")) | ++-----------------------------------------------------------------------------------+ +| true | ++-----------------------------------------------------------------------------------+ + +nebula> RETURN ST_dwithin(ST_GeogFromText("Point(0 0)"),ST_GeogFromText("Point(10 10)"),20000000000.0); ++---------------------------------------------------------------------------------------+ +| ST_dwithin(ST_GeogFromText("Point(0 0)"),ST_GeogFromText("Point(10 10)"),20000000000) | ++---------------------------------------------------------------------------------------+ +| true | ++---------------------------------------------------------------------------------------+ + +nebula> RETURN ST_Distance(ST_GeogFromText("Point(0 0)"),ST_GeogFromText("Point(10 10)")); ++----------------------------------------------------------------------------+ +| ST_Distance(ST_GeogFromText("Point(0 0)"),ST_GeogFromText("Point(10 10)")) | ++----------------------------------------------------------------------------+ +| 1568523.0187677438 | ++----------------------------------------------------------------------------+ + +nebula> RETURN S2_CellIdFromPoint(ST_GeogFromText("Point(1 1)")); ++---------------------------------------------------+ +| S2_CellIdFromPoint(ST_GeogFromText("Point(1 1)")) | ++---------------------------------------------------+ +| 1153277837650709461 | ++---------------------------------------------------+ + +nebula> RETURN S2_CoveringCellIds(ST_GeogFromText("POLYGON((0 1, 1 2, 2 3, 0 1))")); ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| S2_CoveringCellIds(ST_GeogFromText("POLYGON((0 1, 1 2, 2 3, 0 1))")) | ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| [1152391494368201343, 1153466862374223872, 1153554823304445952, 1153836298281156608, 1153959443583467520, 1154240918560178176, 1160503736791990272, 1160591697722212352] | ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +``` 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 1630d5477a1..b8950bcc8f5 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 @@ -1,25 +1,61 @@ # Schema函数 -!!! note +Nebula Graph支持以下Schema函数。 - 本文介绍的函数仅适用于openCypher兼容语句。 +## 原生nGQL语句适用 -Nebula Graph支持以下Schema函数。 +!!! note + + - GO语句中,WHERE子句和YIELD子句中可以使用如下函数。 + - LOOKUP语句中,YIELD子句中可以使用如下函数。 + - FETCH语句中,YIELD子句中可以使用如下函数。 |函数| 说明 | |:---- | :----| -| id(vertex) | 返回点ID。数据类型和点ID的类型保持一致。| -|list tags(vertex) | 返回点的Tag。| -|list labels(vertex) | 返回点的Tag。| -|map properties(vertex_or_edge) | 接收点或边并返回其属性。| +|id(vertex) | 返回点ID。数据类型和点ID的类型保持一致。| +|map properties(vertex) | 返回点的所有属性。| +|map properties(edge) | 返回边的所有属性。| |string type(edge) | 返回边的Edge type。| -|vertex startNode(path) | 获取一条边或一条路径并返回它的起始点ID。| -|string endNode(path) | 获取一条边或一条路径并返回它的目的点ID。| +|src(edge)|返回边的起始点ID。数据类型和点ID的类型保持一致。| +|dst(edge)|返回边的目的点ID。数据类型和点ID的类型保持一致。| |int rank(edge) | 返回边的rank。| +## openCypher兼容语句适用 + +|函数| 说明 | +|:---- | :----| +| id() | 返回点ID。数据类型和点ID的类型保持一致。| +|list tags() | 返回点的Tag,与labels()作用相同。| +|list labels() | 返回点的Tag,与tags()作用相同,用于兼容openCypher语法。| +|map properties() | 返回点或边的所有属性。| +|string type() | 返回边的Edge type。| +|src()|返回边的起始点ID。数据类型和点ID的类型保持一致。| +|dst()|返回边的目的点ID。数据类型和点ID的类型保持一致。| +|vertex startNode() | 获取一条边或一条路径并返回它的起始点ID。| +|string endNode() | 获取一条边或一条路径并返回它的目的点ID。| +|int rank() | 返回边的rank。| + ## 示例 ```ngql +nebula> GO FROM "player100" OVER follow REVERSELY \ + YIELD src(edge) AS destination; ++-------------+ +| destination | ++-------------+ +| "player101" | +| "player102" | ++-------------+ + +nebula> LOOKUP ON player WHERE player.age > 45 YIELD id(vertex); ++-------------+-------------+ +| VertexID | id(VERTEX) | ++-------------+-------------+ +| "player144" | "player144" | +| "player140" | "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/6.functions-and-expressions/5.case-expressions.md b/docs-2.0/3.ngql-guide/6.functions-and-expressions/5.case-expressions.md index bb0c7c77044..e77031f068a 100644 --- a/docs-2.0/3.ngql-guide/6.functions-and-expressions/5.case-expressions.md +++ b/docs-2.0/3.ngql-guide/6.functions-and-expressions/5.case-expressions.md @@ -46,20 +46,19 @@ nebula> RETURN \ ```ngql nebula> GO FROM "player100" OVER follow \ - YIELD $$.player.name AS Name, \ - CASE $$.player.age > 35 \ + YIELD properties($$).name AS Name, \ + CASE properties($$).age > 35 \ WHEN true THEN "Yes" \ WHEN false THEN "No" \ ELSE "Nah" \ END \ AS Age_above_35; -+---------------------+--------------+ -| Name | Age_above_35 | -+---------------------+--------------+ -| "Tony Parker" | "Yes" | -+---------------------+--------------+ -| "LaMarcus Aldridge" | "No" | -+---------------------+--------------+ ++-----------------+--------------+ +| Name | Age_above_35 | ++-----------------+--------------+ +| "Tony Parker" | "Yes" | +| "Manu Ginobili" | "Yes" | ++-----------------+--------------+ ``` ## 通用形式 @@ -108,9 +107,7 @@ nebula> MATCH (v:player) WHERE v.age > 30 \ | Name | Starts_with_T | +---------------------+---------------+ | "Tim" | "Yes" | -+---------------------+---------------+ | "LaMarcus Aldridge" | "No" | -+---------------------+---------------+ | "Tony Parker" | "Yes" | +---------------------+---------------+ ``` @@ -121,19 +118,18 @@ nebula> MATCH (v:player) WHERE v.age > 30 \ ```ngql nebula> GO FROM "player100" OVER follow \ - YIELD $$.player.name AS Name, $$.player.age AS Age, \ - CASE $$.player.age \ - WHEN $$.player.age > 35 THEN "Yes" \ + YIELD properties($$).name AS Name, properties($$).age AS Age, \ + CASE properties($$).age \ + WHEN properties($$).age > 35 THEN "Yes" \ ELSE "No" \ END \ AS Age_above_35; -+---------------------+-----+--------------+ -| Name | Age | Age_above_35 | -+---------------------+-----+--------------+ -| "Tony Parker" | 36 | "No" | -+---------------------+-----+--------------+ -| "LaMarcus Aldridge" | 33 | "No" | -+---------------------+-----+--------------+ ++-----------------+-----+--------------+ +| Name | Age | Age_above_35 | ++-----------------+-----+--------------+ +| "Tony Parker" | 36 | "No" | +| "Manu Ginobili" | 41 | "No" | ++-----------------+-----+--------------+ ``` 示例本意为当玩家年龄大于35时输出`Yes`。但是查看输出结果,年龄为36时输出的却是`No`。 diff --git a/docs-2.0/3.ngql-guide/6.functions-and-expressions/6.list.md b/docs-2.0/3.ngql-guide/6.functions-and-expressions/6.list.md index 7a7dc216ae5..bbb53d26732 100644 --- a/docs-2.0/3.ngql-guide/6.functions-and-expressions/6.list.md +++ b/docs-2.0/3.ngql-guide/6.functions-and-expressions/6.list.md @@ -38,9 +38,7 @@ nebula> MATCH (a:player)-[r]->() \ | labels(a) | keys(r) | +------------+----------------------------+ | ["player"] | ["degree"] | -+------------+----------------------------+ | ["player"] | ["degree"] | -+------------+----------------------------+ | ["player"] | ["end_year", "start_year"] | +------------+----------------------------+ @@ -51,7 +49,6 @@ nebula> MATCH p = (a:player)-[]->(b)-[]->(c:team) \ | nodes(p) | +-----------------------------------------------------------------------------------------------------------------------------------------------+ | [("player100" :player{age: 42, name: "Tim Duncan"}), ("player101" :player{age: 36, name: "Tony Parker"}), ("team204" :team{name: "Spurs"})] | -+-----------------------------------------------------------------------------------------------------------------------------------------------+ | [("player100" :player{age: 42, name: "Tim Duncan"}), ("player125" :player{age: 41, name: "Manu Ginobili"}), ("team204" :team{name: "Spurs"})] | +-----------------------------------------------------------------------------------------------------------------------------------------------+ @@ -60,7 +57,6 @@ nebula> MATCH p = (a:player)-[]->(b)-[]->(c:team) WHERE a.name == "Tim Duncan" A | relationships(p) | +-----------------------------------------------------------------------------------------------------------------------------+ | [[:follow "player100"->"player101" @0 {degree: 95}], [:serve "player101"->"team204" @0 {end_year: 2018, start_year: 1999}]] | -+-----------------------------------------------------------------------------------------------------------------------------+ | [[:follow "player100"->"player125" @0 {degree: 95}], [:serve "player125"->"team204" @0 {end_year: 2018, start_year: 2002}]] | +-----------------------------------------------------------------------------------------------------------------------------+ ``` diff --git a/docs-2.0/3.ngql-guide/6.functions-and-expressions/7.count.md b/docs-2.0/3.ngql-guide/6.functions-and-expressions/7.count.md index 8b2c5ca22f5..d76530d06ef 100644 --- a/docs-2.0/3.ngql-guide/6.functions-and-expressions/7.count.md +++ b/docs-2.0/3.ngql-guide/6.functions-and-expressions/7.count.md @@ -33,22 +33,17 @@ nebula> WITH [NULL, 1, 1, 2, 2] As a UNWIND a AS b \ ```ngql # 返回player101 follow的人,以及follow player101的人,即双向查询。 nebula> GO FROM "player101" OVER follow BIDIRECT \ - YIELD $$.player.name AS Name \ + YIELD properties($$).name AS Name \ | GROUP BY $-.Name YIELD $-.Name, count(*); +---------------------+----------+ | $-.Name | count(*) | +---------------------+----------+ -| "Dejounte Murray" | 1 | -+---------------------+----------+ | "LaMarcus Aldridge" | 2 | -+---------------------+----------+ | "Tim Duncan" | 2 | -+---------------------+----------+ | "Marco Belinelli" | 1 | -+---------------------+----------+ | "Manu Ginobili" | 1 | -+---------------------+----------+ | "Boris Diaw" | 1 | +| "Dejounte Murray" | 1 | +---------------------+----------+ ``` @@ -71,13 +66,9 @@ nebula> LOOKUP ON player \ | age | number | +-----+--------+ | 34 | 4 | -+-----+--------+ | 33 | 4 | -+-----+--------+ | 30 | 4 | -+-----+--------+ | 29 | 4 | -+-----+--------+ | 38 | 3 | +-----+--------+ ... @@ -90,13 +81,9 @@ nebula> MATCH (n:player) \ | age | number | +-----+--------+ | 34 | 4 | -+-----+--------+ | 33 | 4 | -+-----+--------+ | 30 | 4 | -+-----+--------+ | 29 | 4 | -+-----+--------+ | 38 | 3 | +-----+--------+ ... diff --git a/docs-2.0/3.ngql-guide/6.functions-and-expressions/8.predicate.md b/docs-2.0/3.ngql-guide/6.functions-and-expressions/8.predicate.md index bf2a0a31e83..caf67139122 100644 --- a/docs-2.0/3.ngql-guide/6.functions-and-expressions/8.predicate.md +++ b/docs-2.0/3.ngql-guide/6.functions-and-expressions/8.predicate.md @@ -68,15 +68,10 @@ nebula> MATCH p = (n:player{name:"LeBron James"})<-[:follow]-(m) \ | n1 | n2 | b | +----------------+-------------------+-------+ | "LeBron James" | "Danny Green" | false | -+----------------+-------------------+-------+ | "LeBron James" | "Dejounte Murray" | false | -+----------------+-------------------+-------+ | "LeBron James" | "Chris Paul" | true | -+----------------+-------------------+-------+ | "LeBron James" | "Kyrie Irving" | true | -+----------------+-------------------+-------+ | "LeBron James" | "Carmelo Anthony" | true | -+----------------+-------------------+-------+ | "LeBron James" | "Dwyane Wade" | false | +----------------+-------------------+-------+ @@ -98,13 +93,13 @@ nebula> MATCH (n:player) \ ... nebula> MATCH (n:player) \ - WHERE exists(n['name']) RETURN n; -+-------------------------------------------------------------------------------------------------------------+ -| n | -+-------------------------------------------------------------------------------------------------------------+ -| ("Grant Hill" :player{age: 46, name: "Grant Hill"}) | -+-------------------------------------------------------------------------------------------------------------+ -| ("Marc Gasol" :player{age: 34, name: "Marc Gasol"}) | -+-------------------------------------------------------------------------------------------------------------+ + WHERE exists(n['name']) \ + RETURN n; ++---------------------------------------------------------------+ +| n | ++---------------------------------------------------------------+ +| ("player105" :player{age: 31, name: "Danny Green"}) | +| ("player109" :player{age: 34, name: "Tiago Splitter"}) | +| ("player111" :player{age: 38, name: "David West"}) | ... ``` diff --git a/docs-2.0/3.ngql-guide/7.general-query-statements/2.match.md b/docs-2.0/3.ngql-guide/7.general-query-statements/2.match.md index 9592d517619..a4cab0edb37 100644 --- a/docs-2.0/3.ngql-guide/7.general-query-statements/2.match.md +++ b/docs-2.0/3.ngql-guide/7.general-query-statements/2.match.md @@ -11,7 +11,7 @@ 与`GO`或`LOOKUP`等其他查询语句相比,`MATCH`的语法更灵活。`MATCH`语法可以概括如下: ```ngql -MATCH [] RETURN +MATCH [] RETURN ; ``` ## MATCH工作流程 @@ -44,18 +44,18 @@ MATCH [] RETURN ```ngql # 在Tag player的name属性和Edge type follow上创建索引。 -nebula> CREATE TAG INDEX name ON player(name(20)); +nebula> CREATE TAG INDEX name ON player(name(20)); nebula> CREATE EDGE INDEX follow_index on follow(); # 重建索引使其生效。 -nebula> REBUILD TAG INDEX name; +nebula> REBUILD TAG INDEX name; +------------+ | New Job Id | +------------+ | 121 | +------------+ -nebula> REBUILD EDGE INDEX follow_index +nebula> REBUILD EDGE INDEX follow_index; +------------+ | New Job Id | +------------+ @@ -64,31 +64,25 @@ nebula> REBUILD EDGE INDEX follow_index # 确认重建索引成功。 -nebula> SHOW JOB 121; -+----------------+---------------------+------------+-------------------------+-------------------------+ -| Job Id(TaskId) | Command(Dest) | Status | Start Time | Stop Time | -+----------------+---------------------+------------+-------------------------+-------------------------+ -| 121 | "REBUILD_TAG_INDEX" | "FINISHED" | 2021-05-27T02:18:02.000 | 2021-05-27T02:18:02.000 | -+----------------+---------------------+------------+-------------------------+-------------------------+ -| 0 | "storaged1" | "FINISHED" | 2021-05-27T02:18:02.000 | 2021-05-27T02:18:02.000 | -+----------------+---------------------+------------+-------------------------+-------------------------+ -| 1 | "storaged0" | "FINISHED" | 2021-05-27T02:18:02.000 | 2021-05-27T02:18:02.000 | -+----------------+---------------------+------------+-------------------------+-------------------------+ -| 2 | "storaged2" | "FINISHED" | 2021-05-27T02:18:02.000 | 2021-05-27T02:18:02.000 | -+----------------+---------------------+------------+-------------------------+-------------------------+ - -nebula> SHOW JOB 122; -+----------------+----------------------+------------+-------------------------+-------------------------+ -| Job Id(TaskId) | Command(Dest) | Status | Start Time | Stop Time | -+----------------+----------------------+------------+-------------------------+-------------------------+ -| 122 | "REBUILD_EDGE_INDEX" | "FINISHED" | 2021-05-27T02:18:11.000 | 2021-05-27T02:18:11.000 | -+----------------+----------------------+------------+-------------------------+-------------------------+ -| 0 | "storaged1" | "FINISHED" | 2021-05-27T02:18:11.000 | 2021-05-27T02:18:21.000 | -+----------------+----------------------+------------+-------------------------+-------------------------+ -| 1 | "storaged0" | "FINISHED" | 2021-05-27T02:18:11.000 | 2021-05-27T02:18:21.000 | -+----------------+----------------------+------------+-------------------------+-------------------------+ -| 2 | "storaged2" | "FINISHED" | 2021-05-27T02:18:11.000 | 2021-05-27T02:18:21.000 | -+----------------+----------------------+------------+-------------------------+-------------------------+ +nebula> SHOW JOB 121; ++----------------+---------------------+------------+----------------------------+----------------------------+ +| Job Id(TaskId) | Command(Dest) | Status | Start Time | Stop Time | ++----------------+---------------------+------------+----------------------------+----------------------------+ +| 121 | "REBUILD_TAG_INDEX" | "FINISHED" | 2021-05-27T02:18:02.000000 | 2021-05-27T02:18:02.000000 | +| 0 | "storaged1" | "FINISHED" | 2021-05-27T02:18:02.000000 | 2021-05-27T02:18:02.000000 | +| 1 | "storaged0" | "FINISHED" | 2021-05-27T02:18:02.000000 | 2021-05-27T02:18:02.000000 | +| 2 | "storaged2" | "FINISHED" | 2021-05-27T02:18:02.000000 | 2021-05-27T02:18:02.000000 | ++----------------+---------------------+------------+----------------------------+----------------------------+ + +nebula> SHOW JOB 122; ++----------------+----------------------+------------+----------------------------+----------------------------+ +| Job Id(TaskId) | Command(Dest) | Status | Start Time | Stop Time | ++----------------+----------------------+------------+----------------------------+----------------------------+ +| 122 | "REBUILD_EDGE_INDEX" | "FINISHED" | 2021-05-27T02:18:11.000000 | 2021-05-27T02:18:11.000000 | +| 0 | "storaged1" | "FINISHED" | 2021-05-27T02:18:11.000000 | 2021-05-27T02:18:21.000000 | +| 1 | "storaged0" | "FINISHED" | 2021-05-27T02:18:11.000000 | 2021-05-27T02:18:21.000000 | +| 2 | "storaged2" | "FINISHED" | 2021-05-27T02:18:11.000000 | 2021-05-27T02:18:21.000000 | ++----------------+----------------------+------------+----------------------------+----------------------------+ ``` ### 匹配点 @@ -104,16 +98,14 @@ nebula> SHOW JOB 122; 用户可以在点的右侧用`:`表示模式中的Tag。 ```ngql -nebula> MATCH (v:player) RETURN v; +nebula> MATCH (v:player) \ + RETURN v; +---------------------------------------------------------------+ | v | +---------------------------------------------------------------+ -| ("player102" :player{age: 33, name: "LaMarcus Aldridge"}) | -+---------------------------------------------------------------+ -| ("player106" :player{age: 25, name: "Kyle Anderson"}) | -+---------------------------------------------------------------+ -| ("player115" :player{age: 40, name: "Kobe Bryant"}) | -+---------------------------------------------------------------+ +| ("player105" :player{age: 31, name: "Danny Green"}) | +| ("player109" :player{age: 34, name: "Tiago Splitter"}) | +| ("player111" :player{age: 38, name: "David West"}) | ... ``` @@ -127,22 +119,25 @@ nebula> MATCH (v:player) RETURN v; ```ngql # 使用属性name搜索匹配的点。 -nebula> MATCH (v:player{name:"Tim Duncan"}) RETURN v; +nebula> MATCH (v:player{name:"Tim Duncan"}) \ + RETURN v; +----------------------------------------------------+ | v | +----------------------------------------------------+ -| ("player100" :player{name: "Tim Duncan", age: 42}) | +| ("player100" :player{age: 42, name: "Tim Duncan"}) | +----------------------------------------------------+ ``` 使用`WHERE`子句也可以实现相同的操作: ```ngql -nebula> MATCH (v:player) WHERE v.name == "Tim Duncan" RETURN v; +nebula> MATCH (v:player) \ + WHERE v.name == "Tim Duncan" \ + RETURN v; +----------------------------------------------------+ | v | +----------------------------------------------------+ -| ("player100" :player{name: "Tim Duncan", age: 42}) | +| ("player100" :player{age: 42, name: "Tim Duncan"}) | +----------------------------------------------------+ ``` @@ -155,7 +150,9 @@ nebula> MATCH (v:player) WHERE v.name == "Tim Duncan" RETURN v; 用户可以使用点ID去匹配点。`id()`函数可以检索点的ID。 ```ngql -nebula> MATCH (v) WHERE id(v) == 'player101' RETURN v; +nebula> MATCH (v) \ + WHERE id(v) == 'player101' \ + RETURN v; +-----------------------------------------------------+ | v | +-----------------------------------------------------+ @@ -167,15 +164,14 @@ nebula> MATCH (v) WHERE id(v) == 'player101' RETURN v; ```ngql nebula> MATCH (v:player { name: 'Tim Duncan' })--(v2) \ - WHERE id(v2) IN ["player101", "player102"] RETURN v2; + WHERE id(v2) IN ["player101", "player102"] \ + RETURN v2; +-----------------------------------------------------------+ | v2 | +-----------------------------------------------------------+ -| ("player101" :player{name: "Tony Parker", age: 36}) | -+-----------------------------------------------------------+ -| ("player102" :player{name: "LaMarcus Aldridge", age: 33}) | -+-----------------------------------------------------------+ -| ("player101" :player{name: "Tony Parker", age: 36}) | +| ("player101" :player{age: 36, name: "Tony Parker"}) | +| ("player101" :player{age: 36, name: "Tony Parker"}) | +| ("player102" :player{age: 33, name: "LaMarcus Aldridge"}) | +-----------------------------------------------------------+ ``` @@ -193,16 +189,10 @@ nebula> MATCH (v:player{name:"Tim Duncan"})--(v2) \ +---------------------+ | Name | +---------------------+ +| "Spurs" | | "Tony Parker" | -+---------------------+ | "LaMarcus Aldridge" | -+---------------------+ | "Marco Belinelli" | -+---------------------+ -| "Danny Green" | -+---------------------+ -| "Aron Baynes" | -+---------------------+ ... ``` @@ -216,9 +206,7 @@ nebula> MATCH (v:player{name:"Tim Duncan"})-->(v2) \ | Name | +-----------------+ | "Spurs" | -+-----------------+ | "Tony Parker" | -+-----------------+ | "Manu Ginobili" | +-----------------+ ``` @@ -231,16 +219,9 @@ nebula> MATCH (v:player{name:"Tim Duncan"})-->(v2)<--(v3) \ +---------------------+ | Name | +---------------------+ -| "Tony Parker" | -+---------------------+ -| "Tiago Splitter" | -+---------------------+ | "Dejounte Murray" | -+---------------------+ -| "Tony Parker" | -+---------------------+ | "LaMarcus Aldridge" | -+---------------------+ +| "Marco Belinelli" | ... ``` @@ -252,16 +233,9 @@ nebula> MATCH (v:player{name:"Tim Duncan"})-->()<--(v3) \ +---------------------+ | Name | +---------------------+ -| "Tony Parker" | -+---------------------+ +| "Dejounte Murray" | | "LaMarcus Aldridge" | -+---------------------+ -| "Rudy Gay" | -+---------------------+ -| "Danny Green" | -+---------------------+ -| "Kyle Anderson" | -+---------------------+ +| "Marco Belinelli" | ... ``` @@ -272,15 +246,13 @@ nebula> MATCH (v:player{name:"Tim Duncan"})-->()<--(v3) \ ```ngql nebula> MATCH p=(v:player{name:"Tim Duncan"})-->(v2) \ RETURN p; -+-------------------------------------------+ -| p | -+-------------------------------------------+ ++--------------------------------------------------------------------------------------------------------------------------------------+ +| p | ++--------------------------------------------------------------------------------------------------------------------------------------+ +| <("player100" :player{age: 42, name: "Tim Duncan"})-[:serve@0 {end_year: 2016, start_year: 1997}]->("team204" :team{name: "Spurs"})> | | <("player100" :player{age: 42, name: "Tim Duncan"})-[:follow@0 {degree: 95}]->("player101" :player{age: 36, name: "Tony Parker"})> | -+-------------------------------------------+ | <("player100" :player{age: 42, name: "Tim Duncan"})-[:follow@0 {degree: 95}]->("player125" :player{age: 41, name: "Manu Ginobili"})> | -+-------------------------------------------+ -| <("player100" :player{age: 42, name: "Tim Duncan"})-[:serve@0 {end_year: 2016, start_year: 1997}]->("team204" :team{name: "Spurs"})> | -+-------------------------------------------+ ++--------------------------------------------------------------------------------------------------------------------------------------+ ``` !!! compatibility "openCypher兼容性" @@ -294,15 +266,12 @@ nebula> MATCH p=(v:player{name:"Tim Duncan"})-->(v2) \ ```ngql nebula> MATCH (v:player{name:"Tim Duncan"})-[e]-(v2) \ RETURN e; -+---------------------------------------------------------------------------+ -| e | -+---------------------------------------------------------------------------+ -| [:follow "player101"->"player100" @0 {degree: 95}] | -+---------------------------------------------------------------------------+ -| [:follow "player102"->"player100" @0 {degree: 75}] | -+---------------------------------------------------------------------------+ -| [:serve "player100"->"team204" @0 {end_year: 2016, start_year: 1997}] | -+---------------------------------------------------------------------------+ ++-----------------------------------------------------------------------+ +| e | ++-----------------------------------------------------------------------+ +| [:serve "player100"->"team204" @0 {end_year: 2016, start_year: 1997}] | +| [:follow "player101"->"player100" @0 {degree: 95}] | +| [:follow "player102"->"player100" @0 {degree: 75}] | ... ``` @@ -316,16 +285,9 @@ nebula> MATCH ()-[e:follow]-() \ +-----------------------------------------------------+ | e | +-----------------------------------------------------+ -| [:follow "player113"->"player119" @0 {degree: 99}] | -+-----------------------------------------------------+ -| [:follow "player130"->"player149" @0 {degree: 80}] | -+-----------------------------------------------------+ -| [:follow "player149"->"player130" @0 {degree: 80}] | -+-----------------------------------------------------+ -| [:follow "player136"->"player117" @0 {degree: 90}] | -+-----------------------------------------------------+ -| [:follow "player142"->"player117" @0 {degree: 90}] | -+-----------------------------------------------------+ +| [:follow "player104"->"player105" @0 {degree: 60}] | +| [:follow "player113"->"player105" @0 {degree: 99}] | +| [:follow "player105"->"player100" @0 {degree: 70}] | ... ``` @@ -344,7 +306,6 @@ nebula> MATCH (v:player{name:"Tim Duncan"})-[e:follow{degree:95}]->(v2) \ | e | +--------------------------------------------------------+ | [:follow "player100"->"player101" @0 {degree: 95}] | -+--------------------------------------------------------+ | [:follow "player100"->"player125" @0 {degree: 95}] | +--------------------------------------------------------+ ``` @@ -360,9 +321,7 @@ nebula> MATCH (v:player{name:"Tim Duncan"})-[e:follow|:serve]->(v2) \ | e | +---------------------------------------------------------------------------+ | [:follow "player100"->"player101" @0 {degree: 95}] | -+---------------------------------------------------------------------------+ | [:follow "player100"->"player125" @0 {degree: 95}] | -+---------------------------------------------------------------------------+ | [:serve "player100"->"team204" @0 {end_year: 2016, start_year: 1997}] | +---------------------------------------------------------------------------+ ``` @@ -374,15 +333,12 @@ nebula> MATCH (v:player{name:"Tim Duncan"})-[e:follow|:serve]->(v2) \ ```ngql nebula> MATCH (v:player{name:"Tim Duncan"})-[]->(v2)<-[e:serve]-(v3) \ RETURN v2, v3; -+------------------------------------+-----------------------------------------------------------+ -| v2 | v3 | -+------------------------------------+-----------------------------------------------------------+ -| ("player204" :team{name: "Spurs"}) | ("player101" :player{name: "Tony Parker", age: 36}) | -+------------------------------------+-----------------------------------------------------------+ -| ("player204" :team{name: "Spurs"}) | ("player102" :player{name: "LaMarcus Aldridge", age: 33}) | -+------------------------------------+-----------------------------------------------------------+ -| ("player204" :team{name: "Spurs"}) | ("player103" :player{age: 32, name: "Rudy Gay"}) | -+------------------------------------+-----------------------------------------------------------+ ++----------------------------------+-----------------------------------------------------------+ +| v2 | v3 | ++----------------------------------+-----------------------------------------------------------+ +| ("team204" :team{name: "Spurs"}) | ("player104" :player{age: 32, name: "Marco Belinelli"}) | +| ("team204" :team{name: "Spurs"}) | ("player101" :player{age: 36, name: "Tony Parker"}) | +| ("team204" :team{name: "Spurs"}) | ("player102" :player{age: 33, name: "LaMarcus Aldridge"}) | ... ``` @@ -396,11 +352,9 @@ nebula> MATCH p=(v:player{name:"Tim Duncan"})-[e:follow*2]->(v2) \ +-----------------------------------------------------------+ | Friends | +-----------------------------------------------------------+ -| ("player100" :player{name: "Tim Duncan", age: 42}) | -+-----------------------------------------------------------+ -| ("player102" :player{name: "LaMarcus Aldridge", age: 33}) | -+-----------------------------------------------------------+ -| ("player125" :player{name: "Manu Ginobili", age: 41}) | +| ("player100" :player{age: 42, name: "Tim Duncan"}) | +| ("player125" :player{age: 41, name: "Manu Ginobili"}) | +| ("player102" :player{age: 33, name: "LaMarcus Aldridge"}) | +-----------------------------------------------------------+ ``` @@ -435,14 +389,10 @@ nebula> MATCH p=(v:player{name:"Tim Duncan"})-[e:follow*1..3]->(v2) \ +-----------------------------------------------------------+ | Friends | +-----------------------------------------------------------+ -| ("player100" :player{age: 42, name: "Tim Duncan"}) | -+-----------------------------------------------------------+ | ("player101" :player{age: 36, name: "Tony Parker"}) | -+-----------------------------------------------------------+ | ("player125" :player{age: 41, name: "Manu Ginobili"}) | -+-----------------------------------------------------------+ -| ("player102" :player{age: 33, name: "LaMarcus Aldridge"}) | -+-----------------------------------------------------------+ +| ("player100" :player{age: 42, name: "Tim Duncan"}) | +... ``` 用户可以使用`DISTINCT`关键字聚合重复结果。 @@ -453,13 +403,10 @@ nebula> MATCH p=(v:player{name:"Tim Duncan"})-[e:follow*1..3]->(v2:player) \ +-----------------------------------------------------------+-----------+ | Friends | count(v2) | +-----------------------------------------------------------+-----------+ -| ("player125" :player{age: 41, name: "Manu Ginobili"}) | 3 | -+-----------------------------------------------------------+-----------+ | ("player102" :player{age: 33, name: "LaMarcus Aldridge"}) | 1 | -+-----------------------------------------------------------+-----------+ | ("player100" :player{age: 42, name: "Tim Duncan"}) | 4 | -+-----------------------------------------------------------+-----------+ | ("player101" :player{age: 36, name: "Tony Parker"}) | 3 | +| ("player125" :player{age: 41, name: "Manu Ginobili"}) | 3 | +-----------------------------------------------------------+-----------+ ``` @@ -471,13 +418,10 @@ nebula> MATCH p=(v:player{name:"Tim Duncan"})-[e:follow*0..3]->(v2:player) \ +-----------------------------------------------------------+-----------+ | Friends | count(v2) | +-----------------------------------------------------------+-----------+ -| ("player125" :player{age: 41, name: "Manu Ginobili"}) | 3 | -+-----------------------------------------------------------+-----------+ -| ("player101" :player{age: 36, name: "Tony Parker"}) | 3 | -+-----------------------------------------------------------+-----------+ | ("player102" :player{age: 33, name: "LaMarcus Aldridge"}) | 1 | -+-----------------------------------------------------------+-----------+ | ("player100" :player{age: 42, name: "Tim Duncan"}) | 5 | +| ("player125" :player{age: 41, name: "Manu Ginobili"}) | 3 | +| ("player101" :player{age: 36, name: "Tony Parker"}) | 3 | +-----------------------------------------------------------+-----------+ ``` @@ -491,15 +435,11 @@ nebula> MATCH p=(v:player{name:"Tim Duncan"})-[e:follow|serve*2]->(v2) \ +-----------------------------------------------------------+ | v2 | +-----------------------------------------------------------+ -| ("player100" :player{name: "Tim Duncan", age: 42}) | -+-----------------------------------------------------------+ -| ("player102" :player{name: "LaMarcus Aldridge", age: 33}) | -+-----------------------------------------------------------+ -| ("player125" :player{name: "Manu Ginobili", age: 41}) | -+-----------------------------------------------------------+ -| ("player204" :team{name: "Spurs"}) | -+-----------------------------------------------------------+ -| ("player215" :team{name: "Hornets"}) | +| ("team204" :team{name: "Spurs"}) | +| ("player100" :player{age: 42, name: "Tim Duncan"}) | +| ("team215" :team{name: "Hornets"}) | +| ("player125" :player{age: 41, name: "Manu Ginobili"}) | +| ("player102" :player{age: 33, name: "LaMarcus Aldridge"}) | +-----------------------------------------------------------+ ``` @@ -515,20 +455,18 @@ nebula> MATCH (v:player{name:"Tim Duncan"}) \ +----------------------------------------------------+ | v | +----------------------------------------------------+ -| ("player100" :player{name: "Tim Duncan", age: 42}) | +| ("player100" :player{age: 42, name: "Tim Duncan"}) | +----------------------------------------------------+ nebula> MATCH (v:player{name:"Tim Duncan"})-[e]->(v2) \ RETURN e; -+---------------------------------------------------------------------------+ -| e | -+---------------------------------------------------------------------------+ -| [:follow "player100"->"player101" @0 {degree: 95}] | -+---------------------------------------------------------------------------+ -| [:follow "player100"->"player125" @0 {degree: 95}] | -+---------------------------------------------------------------------------+ -| [:serve "player100"->"team204" @0 {end_year: 2016, start_year: 1997}] | -+---------------------------------------------------------------------------+ ++-----------------------------------------------------------------------+ +| e | ++-----------------------------------------------------------------------+ +| [:serve "player100"->"team204" @0 {end_year: 2016, start_year: 1997}] | +| [:follow "player100"->"player101" @0 {degree: 95}] | +| [:follow "player100"->"player125" @0 {degree: 95}] | ++-----------------------------------------------------------------------+ ``` ### 检索点ID @@ -604,15 +542,13 @@ nebula> MATCH (v:player{name:"Tim Duncan"}) \ ```ngql nebula> MATCH p=(v:player{name:"Tim Duncan"})-[]->(v2) \ RETURN properties(v2); -+------------------------------------+ -| properties(v2) | -+------------------------------------+ -| {"name":"Spurs"} | -+------------------------------------+ -| {"name":"Tony Parker", "age":36} | -+------------------------------------+ -| {"age":41, "name":"Manu Ginobili"} | -+------------------------------------+ ++----------------------------------+ +| properties(v2) | ++----------------------------------+ +| {name: "Spurs"} | +| {age: 36, name: "Tony Parker"} | +| {age: 41, name: "Manu Ginobili"} | ++----------------------------------+ ``` ### 检索Edge type @@ -625,9 +561,8 @@ nebula> MATCH p=(v:player{name:"Tim Duncan"})-[e]->() \ +----------+ | type(e) | +----------+ -| "follow" | -+----------+ | "serve" | +| "follow" | +----------+ ``` @@ -638,15 +573,13 @@ nebula> MATCH p=(v:player{name:"Tim Duncan"})-[e]->() \ ```ngql nebula> MATCH p=(v:player{name:"Tim Duncan"})-[*3]->() \ RETURN p; -+-------------------------------------------------------------------------------------------------+ -| p | -+-------------------------------------------------------------------------------------------------+ -| <("player100" :player{age: 42, name: "Tim Duncan"})-[:follow@0 {degree: 95}]->("player101" :player{age: 36, name: "Tony Parker"})-[:follow@0 {degree: 90}]->("player102" :player{age: 33, name: "LaMarcus Aldridge"})-[:serve@0 {end_year: 2019, start_year: 2015}]->("team204" :team{name: "Spurs"})> | -+-------------------------------------------------------------------------------------------------+ -| <("player100" :player{age: 42, name: "Tim Duncan"})-[:follow@0 {degree: 95}]->("player101" :player{age: 36, name: "Tony Parker"})-[:follow@0 {degree: 90}]->("player102" :player{age: 33, name: "LaMarcus Aldridge"})-[:serve@0 {end_year: 2015, start_year: 2006}]->("team203" :team{name: "Trail Blazers"})> | -+-------------------------------------------------------------------------------------------------+ -| <("player100" :player{age: 42, name: "Tim Duncan"})-[:follow@0 {degree: 95}]->("player101" :player{age: 36, name: "Tony Parker"})-[:follow@0 {degree: 90}]->("player102" :player{age: 33, name: "LaMarcus Aldridge"})-[:follow@0 {degree: 75}]->("player101" :player{age: 36, name: "Tony Parker"})> | -+-------------------------------------------------------------------------------------------------+ ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| p | ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| <("player100" :player{age: 42, name: "Tim Duncan"})-[:follow@0 {degree: 95}]->("player101" :player{age: 36, name: "Tony Parker"})-[:follow@0 {degree: 90}]->("player102" :player{age: 33, name: "LaMarcus Aldridge"})-[:serve@0 {end_year: 2019, start_year: 2015}]->("team204" :team{name: "Spurs"})> | +| <("player100" :player{age: 42, name: "Tim Duncan"})-[:follow@0 {degree: 95}]->("player101" :player{age: 36, name: "Tony Parker"})-[:follow@0 {degree: 90}]->("player102" :player{age: 33, name: "LaMarcus Aldridge"})-[:serve@0 {end_year: 2015, start_year: 2006}]->("team203" :team{name: "Trail Blazers"})> | +| <("player100" :player{age: 42, name: "Tim Duncan"})-[:follow@0 {degree: 95}]->("player101" :player{age: 36, name: "Tony Parker"})-[:follow@0 {degree: 90}]->("player102" :player{age: 33, name: "LaMarcus Aldridge"})-[:follow@0 {degree: 75}]->("player101" :player{age: 36, name: "Tony Parker"})> | ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ ... ``` @@ -661,9 +594,7 @@ nebula> MATCH p=(v:player{name:"Tim Duncan"})-[]->(v2) \ | nodes(p) | +---------------------------------------------------------------------------------------------------------------------+ | [("player100" :star{} :player{age: 42, name: "Tim Duncan"}), ("player204" :team{name: "Spurs"})] | -+---------------------------------------------------------------------------------------------------------------------+ | [("player100" :star{} :player{age: 42, name: "Tim Duncan"}), ("player101" :player{name: "Tony Parker", age: 36})] | -+---------------------------------------------------------------------------------------------------------------------+ | [("player100" :star{} :player{age: 42, name: "Tim Duncan"}), ("player125" :player{name: "Manu Ginobili", age: 41})] | +---------------------------------------------------------------------------------------------------------------------+ ``` @@ -675,15 +606,13 @@ nebula> MATCH p=(v:player{name:"Tim Duncan"})-[]->(v2) \ ```ngql nebula> MATCH p=(v:player{name:"Tim Duncan"})-[]->(v2) \ RETURN relationships(p); -+-----------------------------------------------------------------------------+ -| relationships(p) | -+-----------------------------------------------------------------------------+ -| [[:follow "player100"->"player101" @0 {degree: 95}]] | -+-----------------------------------------------------------------------------+ -| [[:follow "player100"->"player125" @0 {degree: 95}]] | -+-----------------------------------------------------------------------------+ -| [[:serve "player100"->"team204" @0 {end_year: 2016, start_year: 1997}]] | -+-----------------------------------------------------------------------------+ ++-------------------------------------------------------------------------+ +| relationships(p) | ++-------------------------------------------------------------------------+ +| [[:serve "player100"->"team204" @0 {end_year: 2016, start_year: 1997}]] | +| [[:follow "player100"->"player101" @0 {degree: 95}]] | +| [[:follow "player100"->"player125" @0 {degree: 95}]] | ++-------------------------------------------------------------------------+ ``` ### 检索路径长度 @@ -693,31 +622,22 @@ nebula> MATCH p=(v:player{name:"Tim Duncan"})-[]->(v2) \ ```ngql nebula> MATCH p=(v:player{name:"Tim Duncan"})-[*..2]->(v2) \ RETURN p AS Paths, length(p) AS Length; -+----------------------------------------------------------------------+--------+ -| Paths | Length | -+----------------------------------------------------------------------+--------+ -| <("player100" :player{age: 42, name: "Tim Duncan"})-[:follow@0 {degree: 95}]->("player125" :player{age: 41, name: "Manu Ginobili"})-[:serve@0 {end_year: 2018, start_year: 2002}]->("team204" :team{name: "Spurs"})> | 2 | -+----------------------------------------------------------------------+--------+ -| <("player100" :player{age: 42, name: "Tim Duncan"})-[:follow@0 {degree: 95}]->("player125" :player{age: 41, name: "Manu Ginobili"})-[:follow@0 {degree: 90}]->("player100" :player{age: 42, name: "Tim Duncan"})> | 2 | -+----------------------------------------------------------------------+--------+ -| <("player100" :player{age: 42, name: "Tim Duncan"})-[:follow@0 {degree: 95}]->("player101" :player{age: 36, name: "Tony Parker"})-[:serve@0 {end_year: 2019, start_year: 2018}]->("team215" :team{name: "Hornets"})> | 2 | -+----------------------------------------------------------------------+--------+ -| <("player100" :player{age: 42, name: "Tim Duncan"})-[:follow@0 {degree: 95}]->("player101" :player{age: 36, name: "Tony Parker"})-[:serve@0 {end_year: 2018, start_year: 1999}]->("team204" :team{name: "Spurs"})> | 2 | -+----------------------------------------------------------------------+--------+ -| <("player100" :player{age: 42, name: "Tim Duncan"})-[:follow@0 {degree: 95}]->("player101" :player{age: 36, name: "Tony Parker"})-[:follow@0 {degree: 95}]->("player125" :player{age: 41, name: "Manu Ginobili"})> | 2 | -+----------------------------------------------------------------------+--------+ -| <("player100" :player{age: 42, name: "Tim Duncan"})-[:follow@0 {degree: 95}]->("player101" :player{age: 36, name: "Tony Parker"})-[:follow@0 {degree: 90}]->("player102" :player{age: 33, name: "LaMarcus Aldridge"})> | 2 | -+----------------------------------------------------------------------+--------+ -| <("player100" :player{age: 42, name: "Tim Duncan"})-[:follow@0 {degree: 95}]->("player101" :player{age: 36, name: "Tony Parker"})-[:follow@0 {degree: 95}]->("player100" :player{age: 42, name: "Tim Duncan"})> | 2 | -+----------------------------------------------------------------------+--------+ ++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------+ +| Paths | Length | ++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------+ | <("player100" :player{age: 42, name: "Tim Duncan"})-[:serve@0 {end_year: 2016, start_year: 1997}]->("team204" :team{name: "Spurs"})> | 1 | -+----------------------------------------------------------------------+--------+ +| <("player100" :player{age: 42, name: "Tim Duncan"})-[:follow@0 {degree: 95}]->("player101" :player{age: 36, name: "Tony Parker"})> | 1 | | <("player100" :player{age: 42, name: "Tim Duncan"})-[:follow@0 {degree: 95}]->("player125" :player{age: 41, name: "Manu Ginobili"})> | 1 | -+----------------------------------------------------------------------+--------+ +| <("player100" :player{age: 42, name: "Tim Duncan"})-[:follow@0 {degree: 95}]->("player101" :player{age: 36, name: "Tony Parker"})-[:serve@0 {end_year: 2018, start_year: 1999}]->("team204" :team{name: "Spurs"})> | 2 | +| <("player100" :player{age: 42, name: "Tim Duncan"})-[:follow@0 {degree: 95}]->("player101" :player{age: 36, name: "Tony Parker"})-[:serve@0 {end_year: 2019, start_year: 2018}]->("team215" :team{name: "Hornets"})> | 2 | +| <("player100" :player{age: 42, name: "Tim Duncan"})-[:follow@0 {degree: 95}]->("player101" :player{age: 36, name: "Tony Parker"})-[:follow@0 {degree: 95}]->("player100" :player{age: 42, name: "Tim Duncan"})> | 2 | +| <("player100" :player{age: 42, name: "Tim Duncan"})-[:follow@0 {degree: 95}]->("player101" :player{age: 36, name: "Tony Parker"})-[:follow@0 {degree: 90}]->("player102" :player{age: 33, name: "LaMarcus Aldridge"})> | 2 | +| <("player100" :player{age: 42, name: "Tim Duncan"})-[:follow@0 {degree: 95}]->("player101" :player{age: 36, name: "Tony Parker"})-[:follow@0 {degree: 95}]->("player125" :player{age: 41, name: "Manu Ginobili"})> | 2 | +| <("player100" :player{age: 42, name: "Tim Duncan"})-[:follow@0 {degree: 95}]->("player125" :player{age: 41, name: "Manu Ginobili"})-[:serve@0 {end_year: 2018, start_year: 2002}]->("team204" :team{name: "Spurs"})> | 2 | +| <("player100" :player{age: 42, name: "Tim Duncan"})-[:follow@0 {degree: 95}]->("player125" :player{age: 41, name: "Manu Ginobili"})-[:follow@0 {degree: 90}]->("player100" :player{age: 42, name: "Tim Duncan"})> | 2 | ++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------+ ``` !!! Performance - Nebula Graph {{ nebula.release }} 中 `MATCH` 语句对性能和资源占用进行了初步优化。 - - 较简单的逻辑可以使用 `GO`, `LOOKUP`, `|` 和 `FETCH` 等来替代。 + Nebula Grap中`MATCH`语句的性能和资源占用得到了优化,但对性能要求较高时,仍建议使用 `GO`, `LOOKUP`, `|` 和 `FETCH` 等来替代`MATCH`。 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 e055905a9db..e638acafa72 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 @@ -13,13 +13,10 @@ GO [[ TO] STEPS ] FROM OVER [{REVERSELY | BIDIRECT}] [ WHERE  ] [YIELD [DISTINCT] ] -[| ORDER BY [{ASC | DESC}]] -[| LIMIT [,] ] - -GO [[ TO] STEPS ] FROM -OVER [{REVERSELY | BIDIRECT}] -[ WHERE  ] +[{SAMPLE | LIMIT }] [| GROUP BY {col_name | expr | position} YIELD ] +[| ORDER BY [{ASC | DESC}]] +[| LIMIT [,] ]; ::= [, ...] @@ -36,33 +33,37 @@ OVER [{REVERSELY | BIDIRECT}] !!! note - `GO`语句采用的路径类型是`walk`,即遍历时点和边可以重复。详情请参见[路径](../../1.introduction/2.1.path.md)。 + `GO`语句采用的路径类型是`walk`,即遍历时点和边可以重复。详情参见[路径](../../1.introduction/2.1.path.md)。 - `M TO N STEPS`:遍历`M~N`跳的边。如果`M`为`0`,输出结果和`M`为`1`相同,即`GO 0 TO 2`和`GO 1 TO 2`是相同的。 -- ``:用逗号分隔的点ID列表,或特殊的引用符`$-.id`。详情请参见[管道符](../5.operators/4.pipe.md)。 +- ``:用逗号分隔的点ID列表,或特殊的引用符`$-.id`。详情参见[管道符](../5.operators/4.pipe.md)。 - ``:遍历的Edge type列表。 - `REVERSELY | BIDIRECT`:默认情况下检索的是``的出边(正向),`REVERSELY`表示反向,即检索入边;`BIDIRECT` 为双向,即检索正向和反向,通过返回 `._type` 字段判断方向,其正数为正向,负数为反向。 -- `WHERE `:指定遍历的过滤条件。用户可以在起始点、目的点和边使用`WHERE`子句,还可以结合`AND`、`OR`、`NOT`、`XOR`一起使用。详情请参见[WHERE](../8.clauses-and-options/where.md)。 +- `WHERE `:指定遍历的过滤条件。用户可以在起始点、目的点和边使用`WHERE`子句,还可以结合`AND`、`OR`、`NOT`、`XOR`一起使用。详情参见[WHERE](../8.clauses-and-options/where.md)。 !!! Note 遍历多个Edge type时,`WHERE`子句有一些限制。例如不支持`WHERE edge1.prop1 > edge2.prop2`。 -- `YIELD [DISTINCT] `:指定输出结果。详情请参见[YIELD](../8.clauses-and-options/yield.md)。如果没有指定,默认返回目的点ID。 +- `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。 + +- `SAMPLE `:用于在结果集中取样。详情参见[SAMPLE](../8.clauses-and-options/sample.md)。 -- `ORDER BY`:指定输出结果的排序规则。详情请参见[ORDER BY](../8.clauses-and-options/order-by.md)。 +- `LIMIT `:用于在遍历过程中逐步限制输出数量。详情参见[LIMIT](../8.clauses-and-options/limit.md)。 + +- `GROUP BY`:根据指定属性的值将输出分组。详情参见[GROUP BY](../8.clauses-and-options/group-by.md)。分组后需要再次使用`YIELD`定义需要返回的输出。 + +- `ORDER BY`:指定输出结果的排序规则。详情参见[ORDER BY](../8.clauses-and-options/order-by.md)。 !!! Note - - 没有指定排序规则时,输出结果的顺序不是固定的。 -- `LIMIT`:限制输出结果的行数。详情请参见[LIMIT](../8.clauses-and-options/limit.md)。 + 没有指定排序规则时,输出结果的顺序不是固定的。 -- `GROUP BY`:根据指定属性的值将输出分组。详情请参见[GROUP BY](../8.clauses-and-options/group-by.md)。 +- `LIMIT [,] ]`:限制输出结果的行数。详情参见[LIMIT](../8.clauses-and-options/limit.md)。 ## 示例 @@ -73,7 +74,6 @@ nebula> GO FROM "player102" OVER serve; | serve._dst | +------------+ | "team203" | -+------------+ | "team204" | +------------+ ``` @@ -85,7 +85,6 @@ nebula> GO 2 STEPS FROM "player102" OVER follow; | follow._dst | +-------------+ | "player101" | -+-------------+ | "player125" | +-------------+ ... @@ -94,43 +93,39 @@ nebula> GO 2 STEPS FROM "player102" OVER follow; ```ngql # 添加过滤条件。 nebula> GO FROM "player100", "player102" OVER serve \ - WHERE serve.start_year > 1995 \ - YIELD DISTINCT $$.team.name AS team_name, serve.start_year AS start_year, $^.player.name AS player_name; + WHERE properties(edge).start_year > 1995 \ + YIELD DISTINCT properties($$).name AS team_name, properties(edge).start_year AS start_year, properties($^).name AS player_name; + +-----------------+------------+---------------------+ | team_name | start_year | player_name | +-----------------+------------+---------------------+ | "Spurs" | 1997 | "Tim Duncan" | -+-----------------+------------+---------------------+ | "Trail Blazers" | 2006 | "LaMarcus Aldridge" | -+-----------------+------------+---------------------+ | "Spurs" | 2015 | "LaMarcus Aldridge" | +-----------------+------------+---------------------+ ``` ```ngql -# 遍历多个Edge type。属性没有值时,会显示__EMPTY__。 +# 遍历多个Edge type。属性没有值时,会显示UNKNOWN_PROP。 nebula> GO FROM "player100" OVER follow, serve \ - YIELD follow.degree, serve.start_year; -+---------------+------------------+ -| follow.degree | serve.start_year | -+---------------+------------------+ -| 95 | __EMPTY__ | -+---------------+------------------+ -| 95 | __EMPTY__ | -+---------------+------------------+ -| __EMPTY__ | 1997 | -+---------------+------------------+ + YIELD properties(edge).degree, properties(edge).start_year; ++-------------------------+-----------------------------+ +| properties(EDGE).degree | properties(EDGE).start_year | ++-------------------------+-----------------------------+ +| 95 | UNKNOWN_PROP | +| 95 | UNKNOWN_PROP | +| UNKNOWN_PROP | 1997 | ++-------------------------+-----------------------------+ ``` ```ngql -# 返回player100的入边。 +# 返回player100入方向的邻居点。 nebula> GO FROM "player100" OVER follow REVERSELY \ - YIELD follow._dst AS destination; + YIELD src(edge) AS destination; +-------------+ | destination | +-------------+ | "player101" | -+-------------+ | "player102" | +-------------+ ... @@ -142,7 +137,6 @@ nebula> MATCH (v)<-[e:follow]- (v2) WHERE id(v) == 'player100' \ | destination | +-------------+ | "player101" | -+-------------+ | "player102" | +-------------+ ... @@ -151,17 +145,16 @@ nebula> MATCH (v)<-[e:follow]- (v2) WHERE id(v) == 'player100' \ ```ngql # 查询player100的朋友和朋友所属队伍。 nebula> GO FROM "player100" OVER follow REVERSELY \ - YIELD follow._dst AS id | \ + YIELD src(edge) AS id | \ GO FROM $-.id OVER serve \ - WHERE $^.player.age > 20 \ - YIELD $^.player.name AS FriendOf, $$.team.name AS Team; + WHERE properties($^).age > 20 \ + YIELD properties($^).name AS FriendOf, properties($$).name AS Team; +---------------------+-----------------+ | FriendOf | Team | +---------------------+-----------------+ -| "Tony Parker" | "Spurs" | -+---------------------+-----------------+ -| "Tony Parker" | "Hornets" | -+---------------------+-----------------+ +| "Boris Diaw" | "Spurs" | +| "Boris Diaw" | "Jazz" | +| "Boris Diaw" | "Suns" | ... # 该MATCH查询与上一个GO查询具有相同的语义。 @@ -171,51 +164,21 @@ nebula> MATCH (v)<-[e:follow]- (v2)-[e2:serve]->(v3) \ +---------------------+-----------------+ | FriendOf | Team | +---------------------+-----------------+ -| "Tony Parker" | "Spurs" | -+---------------------+-----------------+ -| "Tony Parker" | "Hornets" | -+---------------------+-----------------+ -... -``` - -```ngql -# 返回player102的出边和入边。 -nebula> GO FROM "player102" OVER follow BIDIRECT \ - YIELD follow._dst AS both; -+-------------+ -| both | -+-------------+ -| "player100" | -+-------------+ -| "player101" | -+-------------+ -... - -# 该MATCH查询与上一个GO查询具有相同的语义。 -nebula> MATCH (v) -[e:follow]-(v2) \ - WHERE id(v)== "player102" \ - RETURN id(v2) AS both; -+-------------+ -| both | -+-------------+ -| "player101" | -+-------------+ -| "player103" | -+-------------+ +| "Boris Diaw" | "Spurs" | +| "Boris Diaw" | "Jazz" | +| "Boris Diaw" | "Suns" | ... ``` ```ngql # 查询player100 1~2跳内的朋友。 nebula> GO 1 TO 2 STEPS FROM "player100" OVER follow \ - YIELD follow._dst AS destination; + YIELD dst(edge) AS destination; +-------------+ | destination | +-------------+ | "player101" | -+-------------+ | "player125" | -+-------------+ ... # 该MATCH查询与上一个GO查询具有相同的语义。 @@ -226,51 +189,46 @@ nebula> MATCH (v) -[e:follow*1..2]->(v2) \ | destination | +-------------+ | "player100" | -+-------------+ | "player102" | -+-------------+ +... ``` ```ngql # 根据年龄分组。 nebula> GO 2 STEPS FROM "player100" OVER follow \ - YIELD follow._src AS src, follow._dst AS dst, $$.player.age AS age \ + YIELD src(edge) AS src, dst(edge) AS dst, properties($$).age AS age \ | GROUP BY $-.dst \ - YIELD $-.dst AS dst, collect_set($-.src) AS src, collect($-.age) AS age + YIELD $-.dst AS dst, collect_set($-.src) AS src, collect($-.age) AS age; +-------------+----------------------------+----------+ | dst | src | age | +-------------+----------------------------+----------+ | "player125" | ["player101"] | [41] | -+-------------+----------------------------+----------+ | "player100" | ["player125", "player101"] | [42, 42] | -+-------------+----------------------------+----------+ | "player102" | ["player101"] | [33] | +-------------+----------------------------+----------+ ``` ```ngql # 分组并限制输出结果的行数。 -nebula> $a = GO FROM "player100" OVER follow YIELD follow._src AS src, follow._dst AS dst; \ +nebula> $a = GO FROM "player100" OVER follow YIELD src(edge) AS src, dst(edge) AS dst; \ GO 2 STEPS FROM $a.dst OVER follow \ - YIELD $a.src AS src, $a.dst, follow._src, follow._dst \ + YIELD $a.src AS src, $a.dst, src(edge), dst(edge) \ | ORDER BY $-.src | OFFSET 1 LIMIT 2; +-------------+-------------+-------------+-------------+ | src | $a.dst | follow._src | follow._dst | +-------------+-------------+-------------+-------------+ | "player100" | "player125" | "player100" | "player101" | -+-------------+-------------+-------------+-------------+ | "player100" | "player101" | "player100" | "player125" | +-------------+-------------+-------------+-------------+ ``` ```ngql # 在多个边上通过IS NOT EMPTY进行判断。 -nebula> GO FROM "player100" OVER * WHERE $$.player.name IS NOT EMPTY YIELD follow._dst; +nebula> GO FROM "player100" OVER follow WHERE properties($$).name IS NOT EMPTY YIELD dst(edge); +-------------+ | follow._dst | +-------------+ | "player125" | -+-------------+ | "player101" | +-------------+ ``` 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 6b117eef57f..0ca2aed5775 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,5 +1,7 @@ # FETCH + + `FETCH`可以获取指定点或边的属性值。 ## OpenCypher兼容性 @@ -11,9 +13,9 @@ ### 语法 ```ngql -FETCH PROP ON {[, tag_name ...] | *} - [, vid ...] -[YIELD ] +FETCH PROP ON {[, tag_name ...] | *} + [, vid ...] +[YIELD [AS ]]; ``` |参数|说明| @@ -21,7 +23,8 @@ FETCH PROP ON {[, tag_name ...] | *} |`tag_name`|Tag名称。| |`*`|表示当前图空间中的所有Tag。| |`vid`|点ID。| -|`output`|指定要返回的信息。详情请参见[`YIELD`](../8.clauses-and-options/yield.md)。如果没有`YIELD`子句,将返回所有匹配的信息。| +|`YIELD`|定义需要返回的输出。除了返回定义的属性,额外返回`VertexID`。详情请参见[`YIELD`](../8.clauses-and-options/yield.md)。如果没有`YIELD`子句,默认返回`vertices_`,包含点的所有信息。| +|`AS`| 设置别名。| ### 基于Tag获取点的属性值 @@ -42,9 +45,9 @@ nebula> FETCH PROP ON player "player100"; ```ngql nebula> FETCH PROP ON player "player100" \ - YIELD player.name; + YIELD properties(vertex).name AS name; +-------------+--------------+ -| VertexID | player.name | +| VertexID | name | +-------------+--------------+ | "player100" | "Tim Duncan" | +-------------+--------------+ @@ -60,9 +63,7 @@ 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"}) | +-----------------------------------------------------------+ ``` @@ -95,7 +96,6 @@ nebula> FETCH PROP ON player, t1 "player100", "player103"; | vertices_ | +----------------------------------------------------------------------------+ | ("player100" :t1{a: "Hello", b: 100} :player{age: 42, name: "Tim Duncan"}) | -+----------------------------------------------------------------------------+ | ("player103" :player{age: 32, name: "Rudy Gay"}) | +----------------------------------------------------------------------------+ ``` @@ -110,9 +110,7 @@ nebula> FETCH PROP ON * "player100", "player106", "team200"; | vertices_ | +----------------------------------------------------------------------------+ | ("player106" :player{age: 25, name: "Kyle Anderson"}) | -+----------------------------------------------------------------------------+ | ("team200" :team{name: "Warriors"}) | -+----------------------------------------------------------------------------+ | ("player100" :t1{a: "Hello", b: 100} :player{age: 42, name: "Tim Duncan"}) | +----------------------------------------------------------------------------+ ``` @@ -132,7 +130,7 @@ FETCH PROP ON -> [@] [, -> FETCH PROP ON serve "player100" -> "team204"; ```ngql nebula> FETCH PROP ON serve "player100" -> "team204" \ - YIELD serve.start_year; -+-------------+------------+-------------+------------------+ -| serve._src | serve._dst | serve._rank | serve.start_year | -+-------------+------------+-------------+------------------+ -| "player100" | "team204" | 0 | 1997 | -+-------------+------------+-------------+------------------+ + YIELD properties(edge).start_year; ++-------------+------------+-------------+-----------------------------+ +| serve._src | serve._dst | serve._rank | properties(EDGE).start_year | ++-------------+------------+-------------+-----------------------------+ +| "player100" | "team204" | 0 | 1997 | ++-------------+------------+-------------+-----------------------------+ ``` ### 获取多条边的属性值 @@ -170,7 +168,6 @@ nebula> FETCH PROP ON serve "player100" -> "team204", "player133" -> "team202"; | edges_ | +-----------------------------------------------------------------------+ | [:serve "player100"->"team204" @0 {end_year: 2016, start_year: 1997}] | -+-----------------------------------------------------------------------+ | [:serve "player133"->"team202" @0 {end_year: 2011, start_year: 2002}] | +-----------------------------------------------------------------------+ ``` @@ -211,36 +208,32 @@ nebula> FETCH PROP ON serve "player100" -> "team204"@1; ```ngql # 返回从点player101开始的follow边的degree值。 nebula> GO FROM "player101" OVER follow \ - YIELD follow._src AS s, follow._dst AS d \ + YIELD src(edge) AS s, dst(edge) AS d \ | FETCH PROP ON follow $-.s -> $-.d \ - YIELD follow.degree; -+-------------+-------------+--------------+---------------+ -| follow._src | follow._dst | follow._rank | follow.degree | -+-------------+-------------+--------------+---------------+ -| "player101" | "player100" | 0 | 95 | -+-------------+-------------+--------------+---------------+ -| "player101" | "player102" | 0 | 90 | -+-------------+-------------+--------------+---------------+ -| "player101" | "player125" | 0 | 95 | -+-------------+-------------+--------------+---------------+ + 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 | ++-------------+-------------+--------------+-------------------------+ ``` 用户也可以通过自定义变量构建类似的查询。 ```ngql nebula> $var = GO FROM "player101" OVER follow \ - YIELD follow._src AS s, follow._dst AS d; \ + YIELD src(edge) AS s, dst(edge) AS d; \ FETCH PROP ON follow $var.s -> $var.d \ - YIELD follow.degree; -+-------------+-------------+--------------+---------------+ -| follow._src | follow._dst | follow._rank | follow.degree | -+-------------+-------------+--------------+---------------+ -| "player101" | "player100" | 0 | 95 | -+-------------+-------------+--------------+---------------+ -| "player101" | "player102" | 0 | 90 | -+-------------+-------------+--------------+---------------+ -| "player101" | "player125" | 0 | 95 | -+-------------+-------------+--------------+---------------+ + 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 | ++-------------+-------------+--------------+-------------------------+ ``` 更多复合语句的详情,请参见[复合查询(子句结构)](../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 c209d9b496c..94d2e40f847 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,5 +1,7 @@ # LOOKUP + + `LOOKUP`根据索引遍历数据。用户可以使用`LOOKUP`实现如下功能: - 根据`WHERE`子句搜索特定数据。 @@ -33,9 +35,9 @@ ## 语法 ```ngql -LOOKUP ON { | } -[WHERE [AND ...]] -[YIELD ]; +LOOKUP ON { | } +[WHERE [AND ...]] +[YIELD [AS ]]; [AS ] [, [AS ] ...]; @@ -43,11 +45,12 @@ LOOKUP ON { | } - `WHERE `:指定遍历的过滤条件,还可以结合布尔运算符AND和OR一起使用。详情请参见[WHERE](../8.clauses-and-options/where.md)。 -- `YIELD `:指定要返回的结果和格式。 +- `YIELD`:定义需要返回的输出。 + + - `LOOKUP`Tag时,除了返回定义的属性,额外返回`VertexID`。如果没有`YIELD`子句,返回`VertexID`。 + - `LOOKUP`Edge type时,除了返回定义的属性,额外返回`起始点ID`、`目的点ID`和`rank`。如果没有`YIELD`子句,返回`起始点ID`、`目的点ID`和`rank`。 -- 如果只有`WHERE`子句,没有`YIELD`子句: - - `LOOKUP`Tag时,返回点ID。 - - `LOOKUP`Edge type时,返回起始点ID、目的点ID和rank。 +- `AS`:设置别名。 ## WHERE语句限制 @@ -56,8 +59,8 @@ LOOKUP ON { | } - `$-`和`$^`。 - 在关系表达式中,不支持运算符两边都有字段名,例如`tagName.prop1 > tagName.prop2`。 - 不支持运算表达式和函数表达式中嵌套AliasProp表达式。 -- 字符串类型索引不支持范围扫描。 - 不支持XOR和NOT运算符。 +- 不支持除`STARTS WITH`之外的字符串操作。 ## 检索点 @@ -75,31 +78,51 @@ nebula> REBUILD TAG INDEX index_player; nebula> LOOKUP ON player \ WHERE player.name == "Tony Parker"; -============ -| VertexID | -============ -| 101 | ------------- ++-------------+ +| VertexID | ++-------------+ +| "player101" | ++-------------+ nebula> LOOKUP ON player \ WHERE player.name == "Tony Parker" \ - YIELD player.name, player.age; -======================================= -| VertexID | player.name | player.age | -======================================= -| 101 | Tony Parker | 36 | ---------------------------------------- + YIELD properties(vertex).name AS name, properties(vertex).age AS age; ++-------------+---------------+-----+ +| VertexID | name | age | ++-------------+---------------+-----+ +| "player101" | "Tony Parker" | 36 | ++-------------+---------------+-----+ nebula> LOOKUP ON player \ - WHERE player.name == "Kobe Bryant" \ - YIELD player.name AS name |\ + WHERE player.age > 45; ++-------------+ +| VertexID | ++-------------+ +| "player140" | +| "player144" | ++-------------+ + +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 | ++-------------+-------------------------+------------------------+ + +nebula> LOOKUP ON player \ + WHERE player.name == "Kobe Bryant"\ + YIELD properties(vertex).name AS name |\ GO FROM $-.VertexID OVER serve \ - YIELD $-.name, serve.start_year, serve.end_year, $$.team.name; -================================================================== -| $-.name | serve.start_year | serve.end_year | $$.team.name | -================================================================== -| Kobe Bryant | 1996 | 2016 | Lakers | ------------------------------------------------------------------- + YIELD $-.name, properties(edge).start_year, properties(edge).end_year, properties($$).name; ++---------------+-----------------------------+---------------------------+---------------------+ +| $-.name | properties(EDGE).start_year | properties(EDGE).end_year | properties($$).name | ++---------------+-----------------------------+---------------------------+---------------------+ +| "Kobe Bryant" | 1996 | 2016 | "Lakers" | ++---------------+-----------------------------+---------------------------+---------------------+ ``` ## 检索边 @@ -121,40 +144,32 @@ nebula> LOOKUP ON follow \ +-------------+-------------+---------+ | SrcVID | DstVID | Ranking | +-------------+-------------+---------+ -| "player101" | "player102" | 0 | -+-------------+-------------+---------+ -| "player133" | "player114" | 0 | -+-------------+-------------+---------+ -| "player133" | "player144" | 0 | -+-------------+-------------+---------+ +| "player150" | "player143" | 0 | +| "player150" | "player137" | 0 | +| "player148" | "player136" | 0 | ... nebula> LOOKUP ON follow \ WHERE follow.degree == 90 \ - YIELD follow.degree; -+-------------+-------------+---------+---------------+ -| SrcVID | DstVID | Ranking | follow.degree | -+-------------+-------------+---------+---------------+ -| "player101" | "player102" | 0 | 90 | -+-------------+-------------+---------+---------------+ -| "player133" | "player114" | 0 | 90 | -+-------------+-------------+---------+---------------+ -| "player133" | "player144" | 0 | 90 | -+-------------+-------------+---------+---------------+ + YIELD properties(edge).degree; ++-------------+-------------+---------+-------------------------+ +| SrcVID | DstVID | Ranking | properties(EDGE).degree | ++-------------+-------------+---------+-------------------------+ +| "player150" | "player143" | 0 | 90 | +| "player150" | "player137" | 0 | 90 | +| "player148" | "player136" | 0 | 90 | ... nebula> LOOKUP ON follow \ WHERE follow.degree == 60 \ - YIELD follow.degree AS Degree |\ + YIELD properties(edge).degree AS Degree |\ GO FROM $-.DstVID OVER serve \ - YIELD $-.DstVID, serve.start_year, serve.end_year, $$.team.name; + 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" | +-------------+------------------+----------------+--------------+ ``` @@ -181,49 +196,48 @@ nebula> LOOKUP ON follow \ nebula> INSERT VERTEX player(name,age) \ VALUES "player100":("Tim Duncan", 42), "player101":("Tony Parker", 36); - + # 列出所有的 player。类似于 MATCH (n:player) RETURN id(n) /*, n */。 - + nebula> LOOKUP ON player; +-------------+ - | _vid | + | VertexID | +-------------+ | "player100" | - +-------------+ | "player101" | +-------------+ ``` -- 查找Edge type为`like`的所有边的信息。 +- 查找Edge type为`follow`的所有边的信息。 ```ngql - nebula> CREATE EDGE like(likeness int); + nebula> CREATE EDGE follow(degree int); - nebula> CREATE EDGE INDEX like_index on like(); + nebula> CREATE EDGE INDEX follow_index on follow(); - nebula> REBUILD EDGE INDEX like_index; + nebula> REBUILD EDGE INDEX follow_index; +------------+ | New Job Id | +------------+ | 88 | +------------+ - nebula> INSERT EDGE like(likeness) \ + nebula> INSERT EDGE follow(degree) \ VALUES "player100"->"player101":(95); - # 列出所有的 like 边。类似于 MATCH (s)-[e:like]->(d) RETURN id(s), rank(e), id(d) /*, type(e) */。 + # 列出所有的 follow 边。类似于 MATCH (s)-[e:follow]->(d) RETURN id(s), rank(e), id(d) /*, type(e) */。 - nebula)> LOOKUP ON like; - +-------------+----------+-------------+ - | _src | _ranking | _dst | - +-------------+----------+-------------+ - | "player100" | 0 | "player101" | - +-------------+----------+-------------+ + nebula)> LOOKUP ON follow; + +-------------+-------------+---------+ + | SrcVID | DstVID | Ranking | + +-------------+-------------+---------+ + | "player100" | "player101" | 0 | + +-------------+-------------+---------+ ``` ## 统计点或边 -统计Tag为`player`的点和Edge type为`like`的边。 +统计Tag为`player`的点和Edge type为`follow`的边。 ```ngql nebula> LOOKUP ON player |\ @@ -231,18 +245,18 @@ nebula> LOOKUP ON player |\ +---------------+ | Player_Number | +---------------+ -| 2 | +| 51 | +---------------+ -nebula> LOOKUP ON like | \ - YIELD COUNT(*) AS Like_Number; -+-------------+ -| Like_Number | -+-------------+ -| 1 | -+-------------+ +nebula> LOOKUP ON follow | \ + YIELD COUNT(*) AS Follow_Number; ++---------------+ +| Follow_Number | ++---------------+ +| 81 | ++---------------+ ``` !!! note - 使用[`show-stats`命令](./6.show/14.show-stats.md)也可以统计点和边。 + 使用[`SHOW STATS`命令](./6.show/14.show-stats.md)也可以统计点和边。 diff --git a/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/11.show-snapshots.md b/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/11.show-snapshots.md index c6dfe43143f..9c055dc4c79 100644 --- a/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/11.show-snapshots.md +++ b/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/11.show-snapshots.md @@ -22,7 +22,6 @@ nebula> SHOW SNAPSHOTS; | Name | Status | Hosts | +--------------------------------+---------+-----------------------------------------------------+ | "SNAPSHOT_2020_12_16_11_13_55" | "VALID" | "storaged0:9779, storaged1:9779, storaged2:9779" | -+--------------------------------+---------+-----------------------------------------------------+ | "SNAPSHOT_2020_12_16_11_14_10" | "VALID" | "storaged0:9779, storaged1:9779, storaged2:9779" | +--------------------------------+---------+-----------------------------------------------------+ -``` \ No newline at end of file +``` diff --git a/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/12.show-spaces.md b/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/12.show-spaces.md index eee9f13bb50..a35afa834c0 100644 --- a/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/12.show-spaces.md +++ b/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/12.show-spaces.md @@ -18,7 +18,6 @@ nebula> SHOW SPACES; | Name | +---------------------+ | "docs" | -+---------------------+ | "basketballplayer" | +---------------------+ -``` \ No newline at end of file +``` diff --git a/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/14.show-stats.md b/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/14.show-stats.md index f5fa3c28b12..6494f56b546 100644 --- a/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/14.show-stats.md +++ b/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/14.show-stats.md @@ -39,17 +39,14 @@ nebula> SUBMIT JOB STATS; # 确认作业执行成功。 nebula> SHOW JOB 98; -+----------------+---------------+------------+------------+------------+ -| Job Id(TaskId) | Command(Dest) | Status | Start Time | Stop Time | -+----------------+---------------+------------+------------+------------+ -| 98 | "STATS" | "FINISHED" | 1606552675 | 1606552675 | -+----------------+---------------+------------+------------+------------+ -| 0 | "storaged2" | "FINISHED" | 1606552675 | 1606552675 | -+----------------+---------------+------------+------------+------------+ -| 1 | "storaged0" | "FINISHED" | 1606552675 | 1606552675 | -+----------------+---------------+------------+------------+------------+ -| 2 | "storaged1" | "FINISHED" | 1606552675 | 1606552675 | -+----------------+---------------+------------+------------+------------+ ++----------------+---------------+------------+----------------------------+----------------------------+ +| Job Id(TaskId) | Command(Dest) | Status | Start Time | Stop Time | ++----------------+---------------+------------+----------------------------+----------------------------+ +| 98 | "STATS" | "FINISHED" | 2021-11-01T09:33:21.000000 | 2021-11-01T09:33:21.000000 | +| 0 | "storaged2" | "FINISHED" | 2021-11-01T09:33:21.000000 | 2021-11-01T09:33:21.000000 | +| 1 | "storaged0" | "FINISHED" | 2021-11-01T09:33:21.000000 | 2021-11-01T09:33:21.000000 | +| 2 | "storaged1" | "FINISHED" | 2021-11-01T09:33:21.000000 | 2021-11-01T09:33:21.000000 | ++----------------+---------------+------------+----------------------------+----------------------------+ # 显示图空间统计信息。 nebula> SHOW STATS; @@ -57,15 +54,10 @@ nebula> SHOW STATS; | Type | Name | Count | +---------+------------+-------+ | "Tag" | "player" | 51 | -+---------+------------+-------+ | "Tag" | "team" | 30 | -+---------+------------+-------+ -| "Edge" | "like" | 81 | -+---------+------------+-------+ +| "Edge" | "follow" | 81 | | "Edge" | "serve" | 152 | -+---------+------------+-------+ | "Space" | "vertices" | 81 | -+---------+------------+-------+ | "Space" | "edges" | 233 | +---------+------------+-------+ ``` diff --git a/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/15.show-tags-edges.md b/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/15.show-tags-edges.md index d522a9fe763..b0c00e31842 100644 --- a/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/15.show-tags-edges.md +++ b/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/15.show-tags-edges.md @@ -18,18 +18,15 @@ nebula> SHOW TAGS; | Name | +----------+ | "player" | -+----------+ | "star" | -+----------+ | "team" | +----------+ nebula> SHOW EDGES; -+---------+ -| Name | -+---------+ -| "like" | -+---------+ -| "serve" | -+---------+ -``` \ No newline at end of file ++----------+ +| Name | ++----------+ +| "follow" | +| "serve" | ++----------+ +``` diff --git a/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/16.show-users.md b/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/16.show-users.md index b530fe5e6d9..1dabf447d9d 100644 --- a/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/16.show-users.md +++ b/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/16.show-users.md @@ -20,7 +20,6 @@ nebula> SHOW USERS; | Account | +---------+ | "root" | -+---------+ | "user1" | +---------+ -``` \ No newline at end of file +``` diff --git a/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/17.show-sessions.md b/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/17.show-sessions.md index da9ebfe7f8f..3b42816c8f3 100644 --- a/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/17.show-sessions.md +++ b/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/17.show-sessions.md @@ -21,34 +21,34 @@ SHOW SESSION ; ```ngql nebula> SHOW SESSIONS; -+------------------+----------+--------------------+----------------------------+----------------------------+---------------+----------+----------------+ -| SessionId | UserName | SpaceName | CreateTime | UpdateTime | GraphAddr | Timezone | ClientIp | -+------------------+----------+--------------------+----------------------------+----------------------------+---------------+----------+----------------+ -| 1623305056644097 | "user1" | "" | 2021-06-10T06:04:16.644097 | 2021-06-10T06:04:16.638039 | "graphd:9669" | 0 | "172.22.xx.xx" | -+------------------+----------+--------------------+----------------------------+----------------------------+---------------+----------+----------------+ -| 1623304491050858 | "root" | "basketballplayer" | 2021-06-10T05:54:51.50858 | 2021-06-10T06:17:31.5417 | "graphd:9669" | 0 | "172.22.xx.xx" | -+------------------+----------+--------------------+----------------------------+----------------------------+---------------+----------+----------------+ - -nebula> SHOW SESSION 1623304491050858; -+--------------+-----------------------------+ -| VariableName | Value | -+--------------+-----------------------------+ -| "SessionID" | 1623304491050858 | -+--------------+-----------------------------+ -| "UserName" | "root" | -+--------------+-----------------------------+ -| "SpaceName" | "basketballplayer" | -+--------------+-----------------------------+ -| "CreateTime" | 2021-06-10T05:54:51.50858 | -+--------------+-----------------------------+ -| "UpdateTime" | 2021-06-10T06:17:34.866137 | -+--------------+-----------------------------+ -| "GraphAddr" | "graphd:9669" | -+--------------+-----------------------------+ -| "Timezone" | 0 | -+--------------+-----------------------------+ -| "ClientIp" | "172.22.xx.xx" | -+--------------+-----------------------------+ ++------------------+----------+--------------------+----------------------------+----------------------------+------------------+----------+--------------------+ +| SessionId | UserName | SpaceName | CreateTime | UpdateTime | GraphAddr | Timezone | ClientIp | ++------------------+----------+--------------------+----------------------------+----------------------------+------------------+----------+--------------------+ +| 1635128818397714 | "root" | "test" | 2021-10-25T02:26:58.397714 | 2021-10-25T08:31:31.846846 | "127.0.0.1:9669" | 0 | "::ffff:127.0.0.1" | +| 1635254859271703 | "root" | "basketballplayer" | 2021-10-26T13:27:39.271703 | 2021-10-26T13:51:38.277704 | "127.0.0.1:9669" | 0 | "::ffff:127.0.0.1" | +| 1634871229727322 | "root" | "basketballplayer" | 2021-10-22T02:53:49.727322 | 2021-10-22T02:53:56.564001 | "127.0.0.1:9669" | 0 | "::ffff:127.0.0.1" | +| 1635750725840229 | "root" | "basketballplayer" | 2021-11-01T07:12:05.840229 | 2021-11-01T09:42:36.883617 | "127.0.0.1:9669" | 0 | "::ffff:127.0.0.1" | +| 1635299224732060 | "root" | "basketballplayer" | 2021-10-27T01:47:04.732060 | 2021-10-27T09:04:31.741126 | "127.0.0.1:9669" | 0 | "::ffff:127.0.0.1" | +| 1634628999765689 | "root" | "" | 2021-10-19T07:36:39.765689 | 2021-10-19T07:36:39.768064 | "127.0.0.1:9669" | 0 | "::ffff:127.0.0.1" | +| 1634886296595136 | "root" | "basketballplayer" | 2021-10-22T07:04:56.595136 | 2021-10-22T09:48:20.299364 | "127.0.0.1:9669" | 0 | "::ffff:127.0.0.1" | +| 1634629179882439 | "root" | "basketballplayer" | 2021-10-19T07:39:39.882439 | 2021-10-19T09:34:52.153145 | "127.0.0.1:9669" | 0 | "::ffff:127.0.0.1" | +| 1635246158961634 | "root" | "basketballplayer" | 2021-10-26T11:02:38.961634 | 2021-10-26T11:02:51.250897 | "127.0.0.1:9669" | 0 | "::ffff:127.0.0.1" | +| 1634785346839017 | "root" | "basketballplayer" | 2021-10-21T03:02:26.839017 | 2021-10-21T11:07:40.911329 | "127.0.0.1:9669" | 0 | "::ffff:127.0.0.1" | ++------------------+----------+--------------------+----------------------------+----------------------------+------------------+----------+--------------------+ + +nebula> SHOW SESSION 1635254859271703; ++--------------+----------------------------+ +| VariableName | Value | ++--------------+----------------------------+ +| "SessionID" | 1635254859271703 | +| "UserName" | "root" | +| "SpaceName" | "basketballplayer" | +| "CreateTime" | 2021-10-26T13:27:39.271703 | +| "UpdateTime" | 2021-10-26T13:51:38.277704 | +| "GraphAddr" | "127.0.0.1:9669" | +| "Timezone" | 0 | +| "ClientIp" | "::ffff:127.0.0.1" | ++--------------+----------------------------+ ``` |参数|说明| diff --git a/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/18.show-queries.md b/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/18.show-queries.md index fc50cc79e1e..934dd306e6f 100644 --- a/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/18.show-queries.md +++ b/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/18.show-queries.md @@ -36,12 +36,11 @@ nebula> SHOW ALL QUERIES; +------------------+-----------------+---------+----------------------+----------------------------+----------------+-----------+---------------------------------------------------------+ # 返回耗时TOP 10的查询。 -nebula> SHOW ALL QUERIES | ORDER BY $-.DurationInUSec DESC | LIMIT 10; +nebula> SHOW ALL QUERIES | ORDER BY $-.DurationInUSec DESC | LIMIT 10; +------------------+-----------------+---------+----------------------+----------------------------+----------------+-----------+-------------------------------------------------------+ | SessionID | ExecutionPlanID | User | Host | StartTime | DurationInUSec | Status | Query | +------------------+-----------------+---------+----------------------+----------------------------+----------------+-----------+-------------------------------------------------------+ | 1625471375320831 | 98 | "user2" | ""192.168.x.x":9669" | 2021-07-05T07:50:24.461779 | 2608176 | "RUNNING" | "MATCH (v:player)-[*1..4]-(v2) RETURN v2 AS Friends;" | -+------------------+-----------------+---------+----------------------+----------------------------+----------------+-----------+-------------------------------------------------------+ | 1625456037718757 | 99 | "user1" | ""192.168.x.x":9669" | 2021-07-05T07:50:24.910616 | 2159333 | "RUNNING" | "MATCH (v:player)-[*1..4]-(v2) RETURN v2 AS Friends;" | +------------------+-----------------+---------+----------------------+----------------------------+----------------+-----------+-------------------------------------------------------+ ``` diff --git a/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/4.show-create-space.md b/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/4.show-create-space.md index a309e207e66..4fb7c5b2c0d 100644 --- a/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/4.show-create-space.md +++ b/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/4.show-create-space.md @@ -14,9 +14,9 @@ SHOW CREATE SPACE ; ```ngql nebula> SHOW CREATE SPACE basketballplayer; -+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------+ -| Space | Create Space | -+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------+ -| "basketballplayer" | "CREATE SPACE `basketballplayer` (partition_num = 10, replica_factor = 1, charset = utf8, collate = utf8_bin, vid_type = FIXED_STRING(32))" | -+--------------------+---------------------------------------------------------------------------------------------------------------------------------------------+ -``` \ No newline at end of file ++--------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+ +| Space | Create Space | ++--------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+ +| "basketballplayer" | "CREATE SPACE `basketballplayer` (partition_num = 10, replica_factor = 1, charset = utf8, collate = utf8_bin, vid_type = FIXED_STRING(32)) ON default" | ++--------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+ +``` diff --git a/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/5.show-create-tags-edges.md b/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/5.show-create-tags-edges.md index 92fd0bc9f3b..c01b3ffec7f 100644 --- a/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/5.show-create-tags-edges.md +++ b/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/5.show-create-tags-edges.md @@ -20,7 +20,7 @@ nebula> SHOW CREATE TAG player; | "player" | "CREATE TAG `player` ( | | | `name` string NULL, | | | `age` int64 NULL | -| | ) ttl_duration = 0, ttl_col = "" | +| | ) ttl_duration = 0, ttl_col = """ | +----------+-----------------------------------+ nebula> SHOW CREATE EDGE follow; diff --git a/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/6.show-hosts.md b/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/6.show-hosts.md index d7a87059612..4b2d19fd453 100644 --- a/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/6.show-hosts.md +++ b/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/6.show-hosts.md @@ -14,46 +14,38 @@ SHOW HOSTS [GRAPH | STORAGE | META]; ```ngql nebula> SHOW HOSTS; -+-------------+-------+----------+--------------+----------------------------------+-----------------------------+ -| Host | Port | Status | Leader count | Leader distribution | Partition distribution | -+-------------+-------+----------+--------------+----------------------------------+-----------------------------+ -| "storaged0" | 9779 | "ONLINE" | 8 | "docs:5, basketballplayer:3" | "docs:5, basketballplayer:3"| -+-------------+-------+----------+--------------+----------------------------------+-----------------------------+ -| "storaged1" | 9779 | "ONLINE" | 9 | "basketballplayer:4, docs:5" | "docs:5, basketballplayer:4"| -+-------------+-------+----------+--------------+----------------------------------+-----------------------------+ -| "storaged2" | 9779 | "ONLINE" | 8 | "basketballplayer:3, docs:5" | "docs:5, basketballplayer:3"| -+-------------+-------+----------+--------------+----------------------------------+-----------------------------+ ++-------------+-------+----------+--------------+----------------------------------+------------------------------+ +| Host | Port | Status | Leader count | Leader distribution | Partition distribution | ++-------------+-------+----------+--------------+----------------------------------+------------------------------+ +| "storaged0" | 9779 | "ONLINE" | 8 | "docs:5, basketballplayer:3" | "docs:5, basketballplayer:3" | +| "storaged1" | 9779 | "ONLINE" | 9 | "basketballplayer:4, docs:5" | "docs:5, basketballplayer:4" | +| "storaged2" | 9779 | "ONLINE" | 8 | "basketballplayer:3, docs:5" | "docs:5, basketballplayer:3" | ++-------------+-------+----------+--------------+----------------------------------+------------------------------+ nebula> SHOW HOSTS GRAPH; -+-----------+------+----------+---------+---------------+------------------------------------------+ -| Host | Port | Status | Role | Git Info Sha | Version | -+-----------+------+----------+---------+--------------+-------------------------------------------+ -| "graphd" | 9669 | "ONLINE" | "GRAPH" | "c397299c" | "2.5.0, Build Time: Aug 19 2021 11:20:18" | -+-----------+------+----------+---------+--------------+-------------------------------------------+ -| "graphd1" | 9669 | "ONLINE" | "GRAPH" | "c397299c" | "2.5.0, Build Time: Aug 19 2021 11:20:18" | -+-----------+------+----------+---------+--------------+-------------------------------------------+ -| "graphd2" | 9669 | "ONLINE" | "GRAPH" | "c397299c" | "2.5.0, Build Time: Aug 19 2021 11:20:18" | -+-----------+------+----------+---------+--------------+-------------------------------------------+ ++-----------+------+----------+---------+---------------+--------+ +| Host | Port | Status | Role | Git Info Sha | Version | ++-----------+------+----------+---------+--------------+---------+ +| "graphd" | 9669 | "ONLINE" | "GRAPH" | "3ba41bd" | "2.6.0" | +| "graphd1" | 9669 | "ONLINE" | "GRAPH" | "3ba41bd" | "2.6.0" | +| "graphd2" | 9669 | "ONLINE" | "GRAPH" | "3ba41bd" | "2.6.0" | ++-----------+------+----------+---------+--------------+---------+ nebula> SHOW HOSTS STORAGE; -+-------------+------+----------+-----------+--------------+-------------------------------------------+ -| Host | Port | Status | Role | Git Info Sha | Version | -+-------------+------+----------+-----------+--------------+-------------------------------------------+ -| "storaged0" | 9779 | "ONLINE" | "STORAGE" | "5b83e5cb" | "2.5.0, Build Time: Aug 19 2021 10:30:28" | -+-------------+------+----------+-----------+--------------+-------------------------------------------+ -| "storaged1" | 9779 | "ONLINE" | "STORAGE" | "5b83e5cb" | "2.5.0, Build Time: Aug 19 2021 10:30:28" | -+-------------+------+----------+-----------+--------------+-------------------------------------------+ -| "storaged2" | 9779 | "ONLINE" | "STORAGE" | "5b83e5cb" | "2.5.0, Build Time: Aug 19 2021 10:30:28" | -+-------------+------+----------+-----------+--------------+-------------------------------------------+ ++-------------+------+----------+-----------+--------------+---------+ +| Host | Port | Status | Role | Git Info Sha | Version | ++-------------+------+----------+-----------+--------------+---------+ +| "storaged0" | 9779 | "ONLINE" | "STORAGE" | "3ba41bd" | "2.6.0" | +| "storaged1" | 9779 | "ONLINE" | "STORAGE" | "3ba41bd" | "2.6.0" | +| "storaged2" | 9779 | "ONLINE" | "STORAGE" | "3ba41bd" | "2.6.0" | ++-------------+------+----------+-----------+--------------+---------+ nebula> SHOW HOSTS META; -+----------+------+----------+--------+--------------+-------------------------------------------+ -| Host | Port | Status | Role | Git Info Sha | Version | -+----------+------+----------+--------+--------------+-------------------------------------------+ -| "metad2" | 9559 | "ONLINE" | "META" | "5b83e5cb" | "2.5.0, Build Time: Aug 19 2021 10:30:28" | -+----------+------+----------+--------+--------------+-------------------------------------------+ -| "metad0" | 9559 | "ONLINE" | "META" | "5b83e5cb" | "2.5.0, Build Time: Aug 19 2021 10:30:28" | -+----------+------+----------+--------+--------------+-------------------------------------------+ -| "metad1" | 9559 | "ONLINE" | "META" | "5b83e5cb" | "2.5.0, Build Time: Aug 19 2021 10:30:28" | -+----------+------+----------+--------+--------------+-------------------------------------------+ ++----------+------+----------+--------+--------------+---------+ +| Host | Port | Status | Role | Git Info Sha | Version | ++----------+------+----------+--------+--------------+---------+ +| "metad2" | 9559 | "ONLINE" | "META" | "3ba41bd" | "2.6.0" | +| "metad0" | 9559 | "ONLINE" | "META" | "3ba41bd" | "2.6.0" | +| "metad1" | 9559 | "ONLINE" | "META" | "3ba41bd" | "2.6.0" | ++----------+------+----------+--------+--------------+---------+ ``` diff --git a/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/7.show-index-status.md b/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/7.show-index-status.md index 73364ee8b70..9b491427250 100644 --- a/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/7.show-index-status.md +++ b/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/7.show-index-status.md @@ -12,19 +12,19 @@ SHOW {TAG | EDGE} INDEX STATUS; ```ngql nebula> SHOW TAG INDEX STATUS; -+----------------+--------------+ -| Name | Index Status | -+----------------+--------------+ -| "like_index_0" | "FINISHED" | -+----------------+--------------+ -| "like1" | "FINISHED" | -+----------------+--------------+ ++------------------------------------+--------------+ +| Name | Index Status | ++------------------------------------+--------------+ +| "date1_index" | "FINISHED" | +| "basketballplayer_all_tag_indexes" | "FINISHED" | +| "any_shape_geo_index" | "FINISHED" | ++------------------------------------+--------------+ nebula> SHOW EDGE INDEX STATUS; +----------------+--------------+ | Name | Index Status | +----------------+--------------+ -| "index_follow" | "FINISHED" | +| "follow_index" | "FINISHED" | +----------------+--------------+ ``` @@ -32,4 +32,4 @@ nebula> SHOW EDGE INDEX STATUS; - [管理作业](../../18.operation-and-maintenance-statements/4.job-statements.md) -- [REBUILD NATIVE INDEX](../../14.native-index-statements/4.rebuild-native-index.md) \ No newline at end of file +- [REBUILD NATIVE INDEX](../../14.native-index-statements/4.rebuild-native-index.md) diff --git a/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/8.show-indexes.md b/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/8.show-indexes.md index dd9ce30a069..a2734488b8c 100644 --- a/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/8.show-indexes.md +++ b/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/8.show-indexes.md @@ -16,11 +16,8 @@ nebula> SHOW TAG INDEXES; | Index Name | By Tag | Columns | +------------------+--------------+-----------------+ | "fix" | "fix_string" | ["p1"] | -+------------------+--------------+-----------------+ | "player_index_0" | "player" | ["name"] | -+------------------+--------------+-----------------+ | "player_index_1" | "player" | ["name", "age"] | -+------------------+--------------+-----------------+ | "var" | "var_string" | ["p1"] | +------------------+--------------+-----------------+ diff --git a/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/9.show-parts.md b/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/9.show-parts.md index cacec9500fd..524f472cba0 100644 --- a/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/9.show-parts.md +++ b/docs-2.0/3.ngql-guide/7.general-query-statements/6.show/9.show-parts.md @@ -16,23 +16,14 @@ nebula> SHOW PARTS; | Partition ID | Leader | Peers | Losts | +--------------+--------------------+--------------------+-------+ | 1 | "192.168.2.1:9779" | "192.168.2.1:9779" | "" | -+--------------+--------------------+--------------------+-------+ | 2 | "192.168.2.2:9779" | "192.168.2.2:9779" | "" | -+--------------+--------------------+--------------------+-------+ | 3 | "192.168.2.3:9779" | "192.168.2.3:9779" | "" | -+--------------+--------------------+--------------------+-------+ | 4 | "192.168.2.1:9779" | "192.168.2.1:9779" | "" | -+--------------+--------------------+--------------------+-------+ | 5 | "192.168.2.2:9779" | "192.168.2.2:9779" | "" | -+--------------+--------------------+--------------------+-------+ | 6 | "192.168.2.3:9779" | "192.168.2.3:9779" | "" | -+--------------+--------------------+--------------------+-------+ | 7 | "192.168.2.1:9779" | "192.168.2.1:9779" | "" | -+--------------+--------------------+--------------------+-------+ | 8 | "192.168.2.2:9779" | "192.168.2.2:9779" | "" | -+--------------+--------------------+--------------------+-------+ | 9 | "192.168.2.3:9779" | "192.168.2.3:9779" | "" | -+--------------+--------------------+--------------------+-------+ | 10 | "192.168.2.1:9779" | "192.168.2.1:9779" | "" | +--------------+--------------------+--------------------+-------+ diff --git a/docs-2.0/3.ngql-guide/7.general-query-statements/7.unwind.md b/docs-2.0/3.ngql-guide/7.general-query-statements/7.unwind.md index 425c0525857..70671579a90 100644 --- a/docs-2.0/3.ngql-guide/7.general-query-statements/7.unwind.md +++ b/docs-2.0/3.ngql-guide/7.general-query-statements/7.unwind.md @@ -18,9 +18,7 @@ nebula> UNWIND [1,2,3] AS n RETURN n; | n | +---+ | 1 | -+---+ | 2 | -+---+ | 3 | +---+ ``` @@ -65,11 +63,11 @@ nebula> MATCH p=(v:player{name:"Tim Duncan"})--(v2) \ +----------------------------------------------------------------------------------------------------------------------+ | collect(r) | +----------------------------------------------------------------------------------------------------------------------+ -| [("player100" :player{age: 42, name: "Tim Duncan"}), ("player101" :player{age: 36, name: "Tony Parker"}), -("team204" :team{name: "Spurs"}), ("player102" :player{age: 33, name: "LaMarcus Aldridge"}), -("player125" :player{age: 41, name: "Manu Ginobili"}), ("player104" :player{age: 32, name: "Marco Belinelli"}), -("player144" :player{age: 47, name: "Shaquile O'Neal"}), ("player105" :player{age: 31, name: "Danny Green"}), -("player113" :player{age: 29, name: "Dejounte Murray"}), ("player107" :player{age: 32, name: "Aron Baynes"}), +| [("player100" :player{age: 42, name: "Tim Duncan"}), ("player101" :player{age: 36, name: "Tony Parker"}), +("team204" :team{name: "Spurs"}), ("player102" :player{age: 33, name: "LaMarcus Aldridge"}), +("player125" :player{age: 41, name: "Manu Ginobili"}), ("player104" :player{age: 32, name: "Marco Belinelli"}), +("player144" :player{age: 47, name: "Shaquile O'Neal"}), ("player105" :player{age: 31, name: "Danny Green"}), +("player113" :player{age: 29, name: "Dejounte Murray"}), ("player107" :player{age: 32, name: "Aron Baynes"}), ("player109" :player{age: 34, name: "Tiago Splitter"}), ("player108" :player{age: 36, name: "Boris Diaw"})] | +----------------------------------------------------------------------------------------------------------------------+ ``` diff --git a/docs-2.0/3.ngql-guide/8.clauses-and-options/group-by.md b/docs-2.0/3.ngql-guide/8.clauses-and-options/group-by.md index 33e76ac52f9..cf410a1e9b0 100644 --- a/docs-2.0/3.ngql-guide/8.clauses-and-options/group-by.md +++ b/docs-2.0/3.ngql-guide/8.clauses-and-options/group-by.md @@ -14,13 +14,9 @@ nebula> MATCH (v:player)<-[:follow]-(:player) RETURN v.name AS Name, count(*) a | Name | cnt | +----------------------+-----+ | "Tim Duncan" | 10 | -+----------------------+-----+ | "LeBron James" | 6 | -+----------------------+-----+ | "Tony Parker" | 5 | -+----------------------+-----+ | "Chris Paul" | 4 | -+----------------------+-----+ | "Manu Ginobili" | 4 | +----------------------+-----+ ... @@ -42,31 +38,22 @@ nebula> MATCH (v:player)<-[:follow]-(:player) RETURN v.name AS Name, count(*) a ```ngql # 查找所有连接到player100的点,并根据他们的姓名进行分组,返回姓名的出现次数。 nebula> GO FROM "player100" OVER follow BIDIRECT \ - YIELD $$.player.name as Name \ + YIELD properties($$).name as Name \ | GROUP BY $-.Name \ YIELD $-.Name as Player, count(*) AS Name_Count; +---------------------+------------+ | Player | Name_Count | +---------------------+------------+ +| "Shaquille O'Neal" | 1 | | "Tiago Splitter" | 1 | -+---------------------+------------+ -| "Aron Baynes" | 1 | -+---------------------+------------+ -| "Boris Diaw" | 1 | -+---------------------+------------+ | "Manu Ginobili" | 2 | -+---------------------+------------+ -| "Dejounte Murray" | 1 | -+---------------------+------------+ -| "Danny Green" | 1 | -+---------------------+------------+ -| "Tony Parker" | 2 | -+---------------------+------------+ -| "Shaquille O'Neal" | 1 | -+---------------------+------------+ +| "Boris Diaw" | 1 | | "LaMarcus Aldridge" | 1 | -+---------------------+------------+ +| "Tony Parker" | 2 | | "Marco Belinelli" | 1 | +| "Dejounte Murray" | 1 | +| "Danny Green" | 1 | +| "Aron Baynes" | 1 | +---------------------+------------+ ``` @@ -75,7 +62,7 @@ nebula> GO FROM "player100" OVER follow BIDIRECT \ ```ngql # 查找所有连接到player100的点,并根据起始点进行分组,返回degree的总和。 nebula> GO FROM "player100" OVER follow \ - YIELD follow._src AS player, follow.degree AS degree \ + YIELD src(edge) AS player, properties(edge).degree AS degree \ | GROUP BY $-.player \ YIELD sum($-.degree); +----------------+ 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 9dd769b54a5..a6dc81e2856 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 @@ -1,60 +1,119 @@ # LIMIT -`LIMIT`子句限制输出结果的行数。 +`LIMIT`子句限制输出结果的行数。`LIMIT`在原生nGQL语句和openCypher兼容语句中的用法有所不同。 -- 在原生nGQL中,必须使用管道符(|),可以忽略偏移量。 +- 在原生nGQL语句中,一般需要在`LIMIT`子句前使用管道符,可以直接在LIMIT语句后设置或者省略偏移量参数。 -- 在OpenCypher兼容语句中,不允许使用管道符,可以使用`SKIP`指明偏移量。 +- 在openCypher兼容语句中,不允许在`LIMIT`子句前使用管道符,可以使用`SKIP`指明偏移量。 !!! Note 在原生nGQL或OpenCypher兼容语句中使用`LIMIT`时,使用`ORDER BY`子句限制输出顺序非常重要,否则会输出一个不可预知的子集。 -## 原生nGQL语法 +!!! compatibility "历史版本兼容性" -在原生nGQL中,`LIMIT`的工作原理与`SQL`相同,必须和管道符一起使用。`LIMIT`子句接收一个或两个参数。参数的值必须是非负整数。 + Nebula Graph 2.6.0中,`GO`语句支持了新的`LIMIT`语法。部分`LIMIT`相关的算子支持计算下推。 + +## 原生nGQL语句中的LIMIT + +在原生nGQL中,`LIMIT`有通用语法和`GO`语句中的专属语法。 + +### 原生nGQL中的通用LIMIT语法 + +原生nGQL中的通用`LIMIT`语法与`SQL`中的`LIMIT`原理相同。`LIMIT`子句接收一个或两个参数,参数的值必须是非负整数,且必须用在管道符之后。语法和说明如下: ```ngql -YIELD -[| LIMIT [,] ]; +... | LIMIT [,] ; ``` |参数|说明| |:--|:--| -|`var`|排序的列或计算结果。| -|`offset_value`|偏移量,即定义从哪一行开始返回。索引从`0`开始。默认值为`0`,表示从第一行开始返回。| +|`offset`|偏移量,即定义从哪一行开始返回。索引从`0`开始。默认值为`0`,表示从第一行开始返回。| |`number_rows`|返回的总行数。| -### 示例 +示例: ```ngql -# 从排序结果中返回第2行开始的3行数据。 +# 从结果中返回最前面的3行数据。 +nebula> LOOKUP ON player |\ + LIMIT 3; ++-------------+ +| VertexID | ++-------------+ +| "player100" | +| "player101" | +| "player102" | ++-------------+ + +# 从排序后结果中返回第2行开始的3行数据。 nebula> GO FROM "player100" OVER follow REVERSELY \ - YIELD $$.player.name AS Friend, $$.player.age AS Age \ + YIELD properties($$).name AS Friend, properties($$).age AS Age \ | ORDER BY $-.Age, $-.Friend \ | LIMIT 1, 3; +-------------------+-----+ | Friend | Age | +-------------------+-----+ | "Danny Green" | 31 | -+-------------------+-----+ | "Aron Baynes" | 32 | -+-------------------+-----+ | "Marco Belinelli" | 32 | +-------------------+-----+ ``` -## OpenCypher兼容语句 +### GO语句中的LIMIT + +`GO`语句中的`LIMIT`除了支持原生nGQL中的通用语法外,还支持根据边限制输出结果数量。 + +语法: + +```ngql + LIMIT ; +``` + +`limit_list`是一个列表,列表中的元素必须为自然数,且元素数量必须与`GO`语句中的`STEPS`的最大数相同。下文以`GO 1 TO 3 STEPS FROM "A" OVER * LIMIT `为例详细介绍`LIMIT`的这种用法。 + +* 列表`limit_list`必须包含3个自然数元素,例如`GO 1 TO 3 STEPS FROM "A" OVER * LIMIT [1,2,4]`。 +* `LIMIT [1,2,4]`中的`1`表示系统在第一步时自动选择1条边继续遍历,`2`表示在第二步时选择2条边继续遍历,`4`表示在第三步时选择4条边继续遍历。 +* 因为`GO 1 TO 3 STEPS`表示返回第一到第三步的所有遍历结果,因此下图中所有红色边和它们的原点与目的点都会被这条`GO`语句匹配上,而黄色边表示`GO`语句遍历时没有选择的路径。如果不是`GO 1 TO 3 STEPS`而是`GO 3 STEPS`,则只会匹配上第三步的红色边和它们两端的点。 + +![LIMIT in GO](limit_in_go_1.png) + +在basketballplayer数据集中的执行示例如下: + +```ngql +nebula> GO 3 STEPS FROM "player100" \ + OVER * \ + YIELD properties($$).name AS NAME, properties($$).age AS Age \ + LIMIT [3,3,3]; ++-----------------+--------------+ +| NAME | Age | ++-----------------+--------------+ +| "Spurs" | UNKNOWN_PROP | +| "Tony Parker" | 36 | +| "Manu Ginobili" | 41 | ++-----------------+--------------+ + +nebula> GO 3 STEPS FROM "player102" \ + OVER * \ + LIMIT [rand32(5),rand32(5),rand32(5)]; ++------------+-------------+---------------------+ +| serve._dst | follow._dst | any_shape_edge._dst | ++------------+-------------+---------------------+ +| "team204" | | | +| "team215" | | | +| | "player100" | | ++------------+-------------+---------------------+ +``` + +## openCypher兼容语句中的LIMIT + +在`MATCH`等openCypher兼容语句中使用LIMIT不需要加管道符。语法和说明如下: ```ngql -RETURN -[SKIP ] -[LIMIT ]; +... [SKIP ] [LIMIT ]; ``` |参数|说明| |:--|:--| -|`var`|排序的列或计算结果。| |`offset`|偏移量,即定义从哪一行开始返回。索引从`0`开始。默认值为`0`,表示从第一行开始返回。| |`number_rows`|返回的总行数量。| @@ -64,7 +123,9 @@ RETURN 两个整数组成的分数表达式会自动向下取整。例如`8/6`向下取整为1。 -### 示例 +### 单独使用LIMIT + +`LIMIT`可以单独使用,返回指定数量的结果。 ```ngql nebula> MATCH (v:player) RETURN v.name AS Name, v.age AS Age \ @@ -73,13 +134,9 @@ nebula> MATCH (v:player) RETURN v.name AS Name, v.age AS Age \ | Name | Age | +-------------------------+-----+ | "Luka Doncic" | 20 | -+-------------------------+-----+ | "Ben Simmons" | 22 | -+-------------------------+-----+ | "Kristaps Porzingis" | 23 | -+-------------------------+-----+ | "Giannis Antetokounmpo" | 24 | -+-------------------------+-----+ | "Kyle Anderson" | 25 | +-------------------------+-----+ @@ -89,18 +146,15 @@ nebula> MATCH (v:player) RETURN v.name AS Name, v.age AS Age \ | Name | Age | +-------------------------+-----+ | "Luka Doncic" | 20 | -+-------------------------+-----+ | "Ben Simmons" | 22 | -+-------------------------+-----+ | "Kristaps Porzingis" | 23 | -+-------------------------+-----+ | "Giannis Antetokounmpo" | 24 | +-------------------------+-----+ ``` -### SKIP示例 +### 单独使用SKIP -用户可以单独使用`SKIP `设置偏移量,后面不需要添加`LIMIT `。 +`SKIP`可以单独使用,用于设置偏移量,返回指定位置之后的数据。 ```ngql nebula> MATCH (v:player{name:"Tim Duncan"}) --> (v2) \ @@ -110,7 +164,6 @@ nebula> MATCH (v:player{name:"Tim Duncan"}) --> (v2) \ | Name | Age | +-----------------+-----+ | "Manu Ginobili" | 41 | -+-----------------+-----+ | "Tony Parker" | 36 | +-----------------+-----+ @@ -124,7 +177,9 @@ nebula> MATCH (v:player{name:"Tim Duncan"}) --> (v2) \ +---------------+-----+ ``` -用户也可以同时使用`SKIP `和`LIMIT `,返回中间的部分数据。 +### 同时使用SKIP与LIMIT + +同时使用`SKIP`与`LIMIT`可以返回从指定位置开始的指定数量的数据。 ```ngql nebula> MATCH (v:player{name:"Tim Duncan"}) --> (v2) \ @@ -136,6 +191,7 @@ nebula> MATCH (v:player{name:"Tim Duncan"}) --> (v2) \ | "Manu Ginobili" | 41 | +-----------------+-----+ ``` + (v2) \ RETURN v2.name AS Name, v2.age AS Age \ ORDER BY Age; -+-----------------+----------+ -| Name | Age | -+-----------------+----------+ -| "Tony Parker" | 36 | -+-----------------+----------+ -| "Manu Ginobili" | 41 | -+-----------------+----------+ -| "Spurs" | __NULL__ | -+-----------------+----------+ ++-----------------+--------------+ +| Name | Age | ++-----------------+--------------+ +| "Tony Parker" | 36 | +| "Manu Ginobili" | 41 | +| "Spurs" | UNKNOWN_PROP | ++-----------------+--------------+ nebula> MATCH (v:player{name:"Tim Duncan"}) --> (v2) \ RETURN v2.name AS Name, v2.age AS Age \ ORDER BY Age DESC; -+-----------------+----------+ -| Name | Age | -+-----------------+----------+ -| "Spurs" | __NULL__ | -+-----------------+----------+ -| "Manu Ginobili" | 41 | -+-----------------+----------+ -| "Tony Parker" | 36 | -+-----------------+----------+ ++-----------------+--------------+ +| Name | Age | ++-----------------+--------------+ +| "Spurs" | UNKNOWN_PROP | +| "Manu Ginobili" | 41 | +| "Tony Parker" | 36 | ++-----------------+--------------+ ``` diff --git a/docs-2.0/3.ngql-guide/8.clauses-and-options/return.md b/docs-2.0/3.ngql-guide/8.clauses-and-options/return.md index 7094d0807e1..f8cca421d65 100644 --- a/docs-2.0/3.ngql-guide/8.clauses-and-options/return.md +++ b/docs-2.0/3.ngql-guide/8.clauses-and-options/return.md @@ -15,7 +15,7 @@ `RETURN`不支持如下openCypher功能: - 使用不在英文字母表中的字符作为变量名。例如: - + ```ngql MATCH (`点1`:player) \ RETURN `点1`; @@ -63,13 +63,9 @@ nebula> MATCH (v:player) \ | v | +---------------------------------------------------------------+ | ("player104" :player{age: 32, name: "Marco Belinelli"}) | -+---------------------------------------------------------------+ | ("player107" :player{age: 32, name: "Aron Baynes"}) | -+---------------------------------------------------------------+ | ("player116" :player{age: 34, name: "LeBron James"}) | -+---------------------------------------------------------------+ | ("player120" :player{age: 29, name: "James Harden"}) | -+---------------------------------------------------------------+ | ("player125" :player{age: 41, name: "Manu Ginobili"}) | +---------------------------------------------------------------+ ... @@ -84,13 +80,9 @@ nebula> MATCH (v:player)-[e]->() \ | e | +------------------------------------------------------------------------------+ | [:follow "player104"->"player100" @0 {degree: 55}] | -+------------------------------------------------------------------------------+ | [:follow "player104"->"player101" @0 {degree: 50}] | -+------------------------------------------------------------------------------+ | [:follow "player104"->"player105" @0 {degree: 60}] | -+------------------------------------------------------------------------------+ | [:serve "player104"->"team200" @0 {end_year: 2009, start_year: 2007}] | -+------------------------------------------------------------------------------+ | [:serve "player104"->"team208" @0 {end_year: 2016, start_year: 2015}] | +------------------------------------------------------------------------------+ ... @@ -108,9 +100,7 @@ nebula> MATCH (v:player) \ | v.name | v.age | +-------------------+-------+ | "Rajon Rondo" | 33 | -+-------------------+-------+ | "Rudy Gay" | 32 | -+-------------------+-------+ | "Dejounte Murray" | 29 | +-------------------+-------+ ``` @@ -134,9 +124,7 @@ nebula> MATCH (v:player{name:"Tim Duncan"})-[e]->(v2) \ | v | e | v2 | +----------------------------------------------------+-----------------------------------------------------------------------+-------------------------------------------------------+ | ("player100" :player{age: 42, name: "Tim Duncan"}) | [:follow "player100"->"player101" @0 {degree: 95}] | ("player101" :player{age: 36, name: "Tony Parker"}) | -+----------------------------------------------------+-----------------------------------------------------------------------+-------------------------------------------------------+ | ("player100" :player{age: 42, name: "Tim Duncan"}) | [:follow "player100"->"player125" @0 {degree: 95}] | ("player125" :player{age: 41, name: "Manu Ginobili"}) | -+----------------------------------------------------+-----------------------------------------------------------------------+-------------------------------------------------------+ | ("player100" :player{age: 42, name: "Tim Duncan"}) | [:serve "player100"->"team204" @0 {end_year: 2016, start_year: 1997}] | ("team204" :team{name: "Spurs"}) | +----------------------------------------------------+-----------------------------------------------------------------------+-------------------------------------------------------+ ``` @@ -169,15 +157,13 @@ nebula> RETURN "Amber" AS Name; ```ngql nebula> MATCH (v:player{name:"Tim Duncan"})-[e]->(v2) \ RETURN v2.name, type(e), v2.age; -+-----------------+----------+----------+ -| v2.name | type(e) | v2.age | -+-----------------+----------+----------+ -| "Tony Parker" | "follow" | 36 | -+-----------------+----------+----------+ -| "Manu Ginobili" | "follow" | 41 | -+-----------------+----------+----------+ -| "Spurs" | "serve" | __NULL__ | -+-----------------+----------+----------+ ++-----------------+----------+--------------+ +| v2.name | type(e) | v2.age | ++-----------------+----------+--------------+ +| "Tony Parker" | "follow" | 36 | +| "Manu Ginobili" | "follow" | 41 | +| "Spurs" | "serve" | UNKNOWN_PROP | ++-----------------+----------+--------------+ ``` ## 返回表达式结果 @@ -191,9 +177,7 @@ nebula> MATCH (v:player{name:"Tony Parker"})-->(v2:player) \ | v2.name | (Hello+ graphs!) | (v2.age>35) | +---------------------+------------------+-------------+ | "Tim Duncan" | "Hello graphs!" | true | -+---------------------+------------------+-------------+ | "LaMarcus Aldridge" | "Hello graphs!" | false | -+---------------------+------------------+-------------+ | "Manu Ginobili" | "Hello graphs!" | true | +---------------------+------------------+-------------+ @@ -211,7 +195,7 @@ nebula> RETURN 3 > 1; | true | +-------+ -RETURN 1+1, rand32(1, 5); +nebula> RETURN 1+1, rand32(1, 5); +-------+-------------+ | (1+1) | rand32(1,5) | +-------+-------------+ @@ -231,19 +215,12 @@ nebula> MATCH (v:player{name:"Tony Parker"})--(v2:player) \ | v2.name | v2.age | +---------------------+--------+ | "Tim Duncan" | 42 | -+---------------------+--------+ | "LaMarcus Aldridge" | 33 | -+---------------------+--------+ | "Marco Belinelli" | 32 | -+---------------------+--------+ | "Boris Diaw" | 36 | -+---------------------+--------+ | "Dejounte Murray" | 29 | -+---------------------+--------+ | "Tim Duncan" | 42 | -+---------------------+--------+ | "LaMarcus Aldridge" | 33 | -+---------------------+--------+ | "Manu Ginobili" | 41 | +---------------------+--------+ @@ -254,15 +231,10 @@ nebula> MATCH (v:player{name:"Tony Parker"})--(v2:player) \ | v2.name | v2.age | +---------------------+--------+ | "Tim Duncan" | 42 | -+---------------------+--------+ | "LaMarcus Aldridge" | 33 | -+---------------------+--------+ | "Marco Belinelli" | 32 | -+---------------------+--------+ | "Boris Diaw" | 36 | -+---------------------+--------+ | "Dejounte Murray" | 29 | -+---------------------+--------+ | "Manu Ginobili" | 41 | +---------------------+--------+ ``` diff --git a/docs-2.0/3.ngql-guide/8.clauses-and-options/sample.md b/docs-2.0/3.ngql-guide/8.clauses-and-options/sample.md new file mode 100644 index 00000000000..b04d0d21cb7 --- /dev/null +++ b/docs-2.0/3.ngql-guide/8.clauses-and-options/sample.md @@ -0,0 +1,52 @@ +# SAMPLE + +`SAMPLE`子句用于在结果集中均匀取样并返回指定数量的数据。 + +!!! compatibility "历史版本兼容性" + + `SAMPLE`是Nebula Graph 2.6.0 新增的子句。 + +`SAMPLE`仅能在`GO`语句中使用,语法如下: + +```ngql + SAMPLE ; +``` + +`sample_list`是一个列表,列表中的元素必须为自然数,且元素数量必须与`GO`语句中的`STEPS`的最大数相同。下文以`GO 1 TO 3 STEPS FROM "A" OVER * SAMPLE `为例详细介绍`SAMPLE`的用法。 + +* 列表`sample_list`必须包含3个自然数元素,例如`GO 1 TO 3 STEPS FROM "A" OVER * SAMPLE [1,2,4]`。 +* `SAMPLE [1,2,4]`中的`1`表示系统在第一步时自动选择1条边继续遍历,`2`表示在第二步时选择2条边继续遍历,`4`表示在第三步时选择4条边继续遍历。如果某一步没有匹配的边或者匹配到的边数量小于指定数量,则按实际数量返回。 +* 因为`GO 1 TO 3 STEPS`表示返回第一到第三步的所有遍历结果,因此下图中所有红色边和它们的原点与目的点都会被这条`GO`语句匹配上,而黄色边表示`GO`语句遍历时没有选择的路径。如果不是`GO 1 TO 3 STEPS`而是`GO 3 STEPS`,则只会匹配上第三步的红色边和它们两端的点。 + +![SAMPLE in GO](sample_in_go.png) + +在basketballplayer数据集中的执行示例如下: + +```ngql +nebula> GO 3 STEPS FROM "player100" \ + OVER * \ + YIELD properties($$).name AS NAME, properties($$).age AS Age \ + SAMPLE [1,2,3]; ++-----------------+--------------+ +| NAME | Age | ++-----------------+--------------+ +| "Spurs" | UNKNOWN_PROP | +| "Tony Parker" | 36 | +| "Manu Ginobili" | 41 | ++-----------------+--------------+ + +nebula> GO 1 TO 3 STEPS FROM "player100" \ + OVER * \ + YIELD properties($$).name AS NAME, properties($$).age AS Age \ + SAMPLE [2,2,2]; ++---------------------+-----+ +| NAME | Age | ++---------------------+-----+ +| "Manu Ginobili" | 41 | +| "Tony Parker" | 36 | +| "Tim Duncan" | 42 | +| "LaMarcus Aldridge" | 33 | +| "Tony Parker" | 36 | +| "Tim Duncan" | 42 | ++---------------------+-----+ +``` diff --git a/docs-2.0/3.ngql-guide/8.clauses-and-options/sample_in_go.png b/docs-2.0/3.ngql-guide/8.clauses-and-options/sample_in_go.png new file mode 100644 index 00000000000..fc23ccb95d7 Binary files /dev/null and b/docs-2.0/3.ngql-guide/8.clauses-and-options/sample_in_go.png differ diff --git a/docs-2.0/3.ngql-guide/8.clauses-and-options/ttl-options.md b/docs-2.0/3.ngql-guide/8.clauses-and-options/ttl-options.md index 11c8b8c9391..41ab7c71456 100644 --- a/docs-2.0/3.ngql-guide/8.clauses-and-options/ttl-options.md +++ b/docs-2.0/3.ngql-guide/8.clauses-and-options/ttl-options.md @@ -10,11 +10,11 @@ TTL(Time To Live)指定属性的存活时间,超时后,该属性就会 - 不能修改带有TTL选项的属性的Schema。 -- TTL 和 INDEX 共存问题: +- TTL和INDEX共存问题: - + 如果已有 INDEX:不能再设置 TTL,即使在没有 INDEX 的属性上设置 TTL 也不行。 + + 如果一个Tag的其中一属性已有INDEX,则不能为其设置TTL,也不能为该Tag的其他属性设置TTL。 - + 如果已有 TTL:可以再添加 INDEX。 + + 如果已有TTL,可以再添加INDEX。 ## 属性过期 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 a94c1226672..08b3f74941e 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 @@ -33,13 +33,9 @@ nebula> MATCH (v:player) \ | v.name | v.age | +-------------------------+-------+ | "Marco Belinelli" | 32 | -+-------------------------+-------+ | "Aron Baynes" | 32 | -+-------------------------+-------+ | "LeBron James" | 34 | -+-------------------------+-------+ | "James Harden" | 29 | -+-------------------------+-------+ | "Manu Ginobili" | 41 | +-------------------------+-------+ ... @@ -48,16 +44,15 @@ nebula> MATCH (v:player) \ ```ngql nebula> GO FROM "player100" \ OVER follow \ - WHERE follow.degree > 90 \ - OR $$.player.age != 33 \ - AND $$.player.name != "Tony Parker"; -+-------------+ -| follow._dst | -+-------------+ -| "player101" | -+-------------+ -| "player125" | -+-------------+ + WHERE properties(edge).degree > 90 \ + OR properties($$).age != 33 \ + AND properties($$).name != "Tony Parker" \ + YIELD properties($$); ++----------------------------------+ +| properties($$) | ++----------------------------------+ +| {age: 41, name: "Manu Ginobili"} | ++----------------------------------+ ``` ### 过滤属性 @@ -74,9 +69,7 @@ nebula> GO FROM "player100" \ | v2.name | v2.age | +----------------------+--------+ | "Luka Doncic" | 20 | - +----------------------+--------+ | "Kristaps Porzingis" | 23 | - +----------------------+--------+ | "Ben Simmons" | 22 | +----------------------+--------+ ``` @@ -89,7 +82,6 @@ nebula> GO FROM "player100" \ | follow._dst | +-------------+ | "player101" | - +-------------+ | "player125" | +-------------+ ``` @@ -104,13 +96,9 @@ nebula> GO FROM "player100" \ | v.name | v.age | +--------------------+-------+ | "Shaquille O'Neal" | 47 | - +--------------------+-------+ | "Steve Nash" | 45 | - +--------------------+-------+ | "Ray Allen" | 43 | - +--------------------+-------+ | "Grant Hill" | 46 | - +--------------------+-------+ | "Tony Parker" | 36 | +--------------------+-------+ ... @@ -124,7 +112,6 @@ nebula> GO FROM "player100" \ | follow._dst | +-------------+ | "player101" | - +-------------+ | "player125" | +-------------+ ``` @@ -152,9 +139,9 @@ nebula> MATCH (v:player) \ | v.name | v.age | +-------------------------+-------+ | "Boris Diaw" | 36 | -+-------------------------+-------+ | "DeAndre Jordan" | 30 | +-------------------------+-------+ +... ``` ### 过滤rank @@ -180,20 +167,17 @@ nebula> INSERT EDGE e1(p1) VALUES "1"->"2"@6:(16); # 通过rank过滤边,查找rank大于2的边。 nebula> GO FROM "1" \ OVER e1 \ - WHERE e1._rank>2 \ - YIELD e1._src, e1._dst, e1._rank AS Rank, e1.p1 | \ + WHERE rank(edge) > 2 \ + YIELD src(edge), dst(edge), rank(edge) AS Rank, properties(edge).p1 | \ ORDER BY $-.Rank DESC; -==================================== -| e1._src | e1._dst | Rank | e1.p1 | -==================================== -| 1 | 2 | 6 | 16 | ------------------------------------- -| 1 | 2 | 5 | 15 | ------------------------------------- -| 1 | 2 | 4 | 14 | ------------------------------------- -| 1 | 2 | 3 | 13 | ------------------------------------- ++-----------+-----------+------+---------------------+ +| src(EDGE) | dst(EDGE) | Rank | properties(EDGE).p1 | ++-----------+-----------+------+---------------------+ +| "1" | "2" | 6 | 16 | +| "1" | "2" | 5 | 15 | +| "1" | "2" | 4 | 14 | +| "1" | "2" | 3 | 13 | ++-----------+-----------+------+---------------------+ ``` ## 过滤字符串 @@ -213,11 +197,8 @@ nebula> MATCH (v:player) \ | v.name | v.age | +------------------+-------+ | "Tracy McGrady" | 39 | -+------------------+-------+ | "Tony Parker" | 36 | -+------------------+-------+ | "Tim Duncan" | 42 | -+------------------+-------+ | "Tiago Splitter" | 34 | +------------------+-------+ ``` @@ -243,9 +224,7 @@ nebula> MATCH (v:player) \ | v.name | v.age | +------------------+-------+ | "Vince Carter" | 42 | -+------------------+-------+ | "Tony Parker" | 36 | -+------------------+-------+ | "Tiago Splitter" | 34 | +------------------+-------+ ``` @@ -262,11 +241,8 @@ nebula> MATCH (v:player) \ | v.name | v.age | +---------------+-------+ | "Paul George" | 28 | -+---------------+-------+ | "Tony Parker" | 36 | -+---------------+-------+ | "Paul Gasol" | 38 | -+---------------+-------+ | "Chris Paul" | 33 | +---------------+-------+ ``` @@ -283,13 +259,9 @@ nebula> MATCH (v:player) \ | v.name | v.age | +-------------------------+-------+ | "Rajon Rondo" | 33 | -+-------------------------+-------+ | "Rudy Gay" | 32 | -+-------------------------+-------+ | "Dejounte Murray" | 29 | -+-------------------------+-------+ | "Chris Paul" | 33 | -+-------------------------+-------+ | "Carmelo Anthony" | 34 | +-------------------------+-------+ ... @@ -323,32 +295,25 @@ nebula> MATCH (v:player) \ | v.name | v.age | +-------------------------+-------+ | "Ben Simmons" | 22 | -+-------------------------+-------+ | "Kristaps Porzingis" | 23 | -+-------------------------+-------+ | "Luka Doncic" | 20 | -+-------------------------+-------+ | "Kyle Anderson" | 25 | -+-------------------------+-------+ | "Giannis Antetokounmpo" | 24 | -+-------------------------+-------+ | "Joel Embiid" | 25 | +-------------------------+-------+ -nebula> LOOKUP ON player WHERE player.age IN [25,28] YIELD player.name, player.age; -+-------------+------------------+------------+ -| VertexID | player.name | player.age | -+-------------+------------------+------------+ -| "player135" | "Damian Lillard" | 28 | -+-------------+------------------+------------+ -| "player131" | "Paul George" | 28 | -+-------------+------------------+------------+ -| "player130" | "Joel Embiid" | 25 | -+-------------+------------------+------------+ -| "player123" | "Ricky Rubio" | 28 | -+-------------+------------------+------------+ -| "player106" | "Kyle Anderson" | 25 | -+-------------+------------------+------------+ +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 | ++-------------+-------------------------+------------------------+ ``` ### 结合NOT使用 @@ -362,14 +327,10 @@ nebula> MATCH (v:player) \ | Name | Age | +---------------------+-----+ | "Kyrie Irving" | 26 | -+---------------------+-----+ | "Cory Joseph" | 27 | -+---------------------+-----+ | "Damian Lillard" | 28 | -+---------------------+-----+ | "Paul George" | 28 | -+---------------------+-----+ | "Ricky Rubio" | 28 | +---------------------+-----+ ... -``` \ No newline at end of file +``` diff --git a/docs-2.0/3.ngql-guide/8.clauses-and-options/with.md b/docs-2.0/3.ngql-guide/8.clauses-and-options/with.md index 4fac767ac9b..645fe58153c 100644 --- a/docs-2.0/3.ngql-guide/8.clauses-and-options/with.md +++ b/docs-2.0/3.ngql-guide/8.clauses-and-options/with.md @@ -26,33 +26,22 @@ nebula> MATCH p=(v:player{name:"Tim Duncan"})--() \ WITH nodes(p) AS n \ UNWIND n AS n1 \ RETURN DISTINCT n1; -+----------------------------------------------------------------------+ -| n1 | -+----------------------------------------------------------------------+ -| ("player100" :star{} :person{} :player{age: 42, name: "Tim Duncan"}) | -+----------------------------------------------------------------------+ -| ("player101" :player{age: 36, name: "Tony Parker"}) | -+----------------------------------------------------------------------+ -| ("team204" :team{name: "Spurs"}) | -+----------------------------------------------------------------------+ -| ("player102" :player{age: 33, name: "LaMarcus Aldridge"}) | -+----------------------------------------------------------------------+ -| ("player125" :player{age: 41, name: "Manu Ginobili"}) | -+----------------------------------------------------------------------+ -| ("player104" :player{age: 32, name: "Marco Belinelli"}) | -+----------------------------------------------------------------------+ -| ("player144" :player{age: 47, name: "Shaquile O'Neal"}) | -+----------------------------------------------------------------------+ -| ("player105" :player{age: 31, name: "Danny Green"}) | -+----------------------------------------------------------------------+ -| ("player113" :player{age: 29, name: "Dejounte Murray"}) | -+----------------------------------------------------------------------+ -| ("player107" :player{age: 32, name: "Aron Baynes"}) | -+----------------------------------------------------------------------+ -| ("player109" :player{age: 34, name: "Tiago Splitter"}) | -+----------------------------------------------------------------------+ -| ("player108" :player{age: 36, name: "Boris Diaw"}) | -+----------------------------------------------------------------------+ ++-----------------------------------------------------------+ +| n1 | ++-----------------------------------------------------------+ +| ("player100" :player{age: 42, name: "Tim Duncan"}) | +| ("player101" :player{age: 36, name: "Tony Parker"}) | +| ("team204" :team{name: "Spurs"}) | +| ("player102" :player{age: 33, name: "LaMarcus Aldridge"}) | +| ("player125" :player{age: 41, name: "Manu Ginobili"}) | +| ("player104" :player{age: 32, name: "Marco Belinelli"}) | +| ("player144" :player{age: 47, name: "Shaquille O'Neal"}) | +| ("player105" :player{age: 31, name: "Danny Green"}) | +| ("player113" :player{age: 29, name: "Dejounte Murray"}) | +| ("player107" :player{age: 32, name: "Aron Baynes"}) | +| ("player109" :player{age: 34, name: "Tiago Splitter"}) | +| ("player108" :player{age: 36, name: "Boris Diaw"}) | ++-----------------------------------------------------------+ ``` ### 示例2 @@ -71,12 +60,8 @@ nebula> MATCH (v) \ +----------+ | tags_f | +----------+ -| "star" | -+----------+ | "player" | +----------+ -| "person" | -+----------+ ``` ## 过滤聚合查询 @@ -93,9 +78,7 @@ nebula> MATCH (v:player)-->(v2:player) \ | Name | Age | +----------------------+-----+ | "Luka Doncic" | 20 | -+----------------------+-----+ | "Ben Simmons" | 22 | -+----------------------+-----+ | "Kristaps Porzingis" | 23 | +----------------------+-----+ ``` 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 cd24625d4bc..90792f80ca2 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 @@ -24,7 +24,7 @@ !!! note 下文示例中的`$$`、`$-`等是引用符号,详情请参见[引用符](../5.operators/5.property-reference.md)。 - + ## YIELD子句 ### 语法 @@ -45,12 +45,11 @@ YIELD [DISTINCT] [AS ] [, [AS ] ...]; ```ngql nebula> GO FROM "player100" OVER follow \ - YIELD $$.player.name AS Friend, $$.player.age AS Age; + YIELD properties($$).name AS Friend, properties($$).age AS Age; +-----------------+-----+ | Friend | Age | +-----------------+-----+ | "Tony Parker" | 36 | - +-----------------+-----+ | "Manu Ginobili" | 41 | +-----------------+-----+ ``` @@ -59,24 +58,24 @@ YIELD [DISTINCT] [AS ] [, [AS ] ...]; ```ngql nebula> FETCH PROP ON player "player100" \ - YIELD player.name; - +-------------+--------------+ - | VertexID | player.name | - +-------------+--------------+ - | "player100" | "Tim Duncan" | - +-------------+--------------+ + YIELD properties(vertex).name; + +-------------+-------------------------+ + | VertexID | properties(VERTEX).name | + +-------------+-------------------------+ + | "player100" | "Tim Duncan" | + +-------------+-------------------------+ ``` - `LOOKUP`语句中使用`YIELD`: ```ngql nebula> LOOKUP ON player WHERE player.name == "Tony Parker" \ - YIELD player.name, player.age; - ======================================= - | VertexID | player.name | player.age | - ======================================= - | 101 | Tony Parker | 36 | - --------------------------------------- + YIELD properties(vertex).name, properties(vertex).age; + +-------------+-------------------------+------------------------+ + | VertexID | properties(VERTEX).name | properties(VERTEX).age | + +-------------+-------------------------+------------------------+ + | "player101" | "Tony Parker" | 36 | + +-------------+-------------------------+------------------------+ ``` ## YIELD语句 @@ -102,9 +101,9 @@ YIELD [DISTINCT] [AS ] [, [AS ] ...] ```ngql # 查找player100关注的player,并计算他们的平均年龄。 nebula> GO FROM "player100" OVER follow \ - YIELD follow._dst AS ID \ + YIELD dst(edge) AS ID \ | FETCH PROP ON player $-.ID \ - YIELD player.age AS Age \ + YIELD properties(vertex).age AS Age \ | YIELD AVG($-.Age) as Avg_age, count(*)as Num_friends; +---------+-------------+ | Avg_age | Num_friends | @@ -116,13 +115,12 @@ nebula> GO FROM "player100" OVER follow \ ```ngql # 查找player101关注的player,返回degree大于90的player。 nebula> $var1 = GO FROM "player101" OVER follow \ - YIELD follow.degree AS Degree, follow._dst as ID; \ + YIELD properties(edge).degree AS Degree, dst(edge) as ID; \ YIELD $var1.ID AS ID WHERE $var1.Degree > 90; +-------------+ | ID | +-------------+ | "player100" | -+-------------+ | "player125" | +-------------+ ``` @@ -165,4 +163,4 @@ nebula> YIELD \ +--------+ | 1 | +--------+ -``` \ No newline at end of file +``` diff --git a/docs-2.0/3.ngql-guide/9.space-statements/1.create-space.md b/docs-2.0/3.ngql-guide/9.space-statements/1.create-space.md index fadabd5dc1f..738bd67743c 100644 --- a/docs-2.0/3.ngql-guide/9.space-statements/1.create-space.md +++ b/docs-2.0/3.ngql-guide/9.space-statements/1.create-space.md @@ -1,6 +1,6 @@ # CREATE SPACE -图空间是Nebula Graph中彼此隔离的图数据集合,与MySQL中的database概念类似。`CREATE SPACE`语句可以通过指定名称创建一个新的图空间。 +图空间是Nebula Graph中彼此隔离的图数据集合,与MySQL中的database概念类似。`CREATE SPACE`语句可以创建一个新的图空间,或者克隆现有图空间的Schema。 ## 前提条件 @@ -8,12 +8,15 @@ ## 语法 +### 创建图空间 + ```ngql CREATE SPACE [IF NOT EXISTS] ( - [partition_num = ,] + [partition_num = ,] [replica_factor = ,] vid_type = {FIXED_STRING() | INT[64]} ) + [ON ] [COMMENT = '']; ``` @@ -24,18 +27,19 @@ CREATE SPACE [IF NOT EXISTS] ( |`partition_num`|指定图空间的分片数量。建议设置为5倍的集群硬盘数量。例如集群中有3个硬盘,建议设置15个分片。默认值为100。| |`replica_factor`|指定每个分片的副本数量。建议在生产环境中设置为3,在测试环境中设置为1。由于需要基于多数表决,副本数量必须是**奇数**。默认值为1。| |`vid_type`|必选参数。指定点ID的数据类型。可选值为`FIXED_STRING()`和`INT64`。`INT`等同于`INT64`。`FIXED_STRING()`表示数据类型为字符串,最大长度为`N`,超出长度会报错;`INT64`表示数据类型为整数。| +|`ON `|指定图空间所属的Group。详情请参见[Group&Zone](../../7.data-security/5.zone.md)。| |`COMMENT`|图空间的描述。最大为256字节。默认无描述。| !!! caution 如果将副本数设置为1,用户将无法使用[BALANCE](../../8.service-tuning/load-balance.md)命令为Nebula Graph的存储服务平衡负载或扩容。 -!!! warning +!!! caution VID类型变更与长度限制 - + 1. 在Nebula Graph 1.x中,VID的类型只能为`INT64`,不支持字符型;在Nebula Graph 2.x中, VID的类型支持`INT64`和`FIXED_STRING()`。请在创建图空间时指定VID类型,使用`INSERT`语句时也需要保持一致,否则会报错VID类型不匹配`Wrong vertex id type: 1001`。 - + 2. VID最大长度必须为`N`,不可任意长度;超过该长度也会报错`The VID must be a 64-bit integer or a string fitting space vertex id length limit.`。 !!! compatibility "历史版本兼容性" @@ -46,25 +50,45 @@ CREATE SPACE [IF NOT EXISTS] ( `graph_space_name`, `partition_num`, `replica_factor`, `vid_type`, `comment` 设置后就无法改变。除非[`DROP SPACE`](./5.drop-space.md),并重新`CREATE SPACE`。 +### 克隆图空间 + +```ngql +CREATE SPACE AS ; +``` + +|参数|说明| +|:---|:---| +|``|目标图空间名称。该图空间必须未创建。图空间名称由大小写英文字母、数字或下划线组成,区分大写小,且不可使用[关键字和保留字](../../3.ngql-guide/1.nGQL-overview/keywords-and-reserved-words.md)。创建时会克隆``图空间的Schema,包括图空间本身参数(分片数量、副本数量等),以及Tag、Edge type和原生索引。| +|``|原始图空间名称。该图空间必须已存在。| + ## 示例 ```ngql # 仅指定VID类型,其他选项使用默认值。 -nebula> CREATE SPACE my_space_1 (vid_type=FIXED_STRING(30)); +nebula> CREATE SPACE my_space_1 (vid_type=FIXED_STRING(30)); # 指定分片数量、副本数量和VID类型。 nebula> CREATE SPACE my_space_2 (partition_num=15, replica_factor=1, vid_type=FIXED_STRING(30)); # 指定分片数量、副本数量和VID类型,并添加描述。 -nebula> CREATE SPACE my_space_3 (partition_num=15, replica_factor=1, vid_type=FIXED_STRING(30)) comment="测试图空间"; +nebula> CREATE SPACE my_space_3 (partition_num=15, replica_factor=1, vid_type=FIXED_STRING(30)) comment="测试图空间"; + +# 克隆图空间。 +nebula> CREATE SPACE my_space_4 as my_space_3; +nebula> SHOW CREATE SPACE my_space_4; ++--------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| Space | Create Space | ++--------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| "my_space_4" | "CREATE SPACE `my_space_4` (partition_num = 15, replica_factor = 1, charset = utf8, collate = utf8_bin, vid_type = FIXED_STRING(30)) ON default comment = '测试图空间'" | ++--------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ ``` -## 创建图空间说明 +## 图空间说明 -!!! warning "立刻尝试使用刚创建的图空间可能会失败,因为创建是异步实现的。" +!!! caution 立刻尝试使用刚创建的图空间可能会失败,因为创建是异步实现的。 - + Nebula Graph将在下一个心跳周期内完成图空间的创建,为了确保创建成功,可以使用如下方法之一: - 在[`SHOW SPACES`](3.show-spaces.md)或[`DESCRIBE SPACE`](4.describe-space.md)语句的结果中查找新的图空间,如果找不到,请等待几秒重试。 @@ -83,11 +107,8 @@ nebula> SHOW HOSTS; | Host | Port | Status | Leader count | Leader distribution | Partition distribution | +-------------+------+----------+--------------+--------------------------------+--------------------------------+ | "storaged0" | 9779 | "ONLINE" | 8 | "basketballplayer:3, test:5" | "basketballplayer:10, test:10" | -+-------------+------+----------+--------------+--------------------------------+--------------------------------+ | "storaged1" | 9779 | "ONLINE" | 9 | "basketballplayer:4, test:5" | "basketballplayer:10, test:10" | -+-------------+------+----------+--------------+--------------------------------+--------------------------------+ | "storaged2" | 9779 | "ONLINE" | 3 | "basketballplayer:3" | "basketballplayer:10, test:10" | -+-------------+------+----------+--------------+--------------------------------+--------------------------------+ | "Total" | | | 20 | "basketballplayer:10, test:10" | "basketballplayer:30, test:30" | +-------------+------+----------+--------------+--------------------------------+--------------------------------+ ``` @@ -100,11 +121,8 @@ nebula> BALANCE LEADER; | Host | Port | Status | Leader count | Leader distribution | Partition distribution | +-------------+------+----------+--------------+--------------------------------+--------------------------------+ | "storaged0" | 9779 | "ONLINE" | 7 | "basketballplayer:3, test:4" | "basketballplayer:10, test:10" | -+-------------+------+----------+--------------+--------------------------------+--------------------------------+ | "storaged1" | 9779 | "ONLINE" | 7 | "basketballplayer:4, test:3" | "basketballplayer:10, test:10" | -+-------------+------+----------+--------------+--------------------------------+--------------------------------+ | "storaged2" | 9779 | "ONLINE" | 6 | "basketballplayer:3, test:3" | "basketballplayer:10, test:10" | -+-------------+------+----------+--------------+--------------------------------+--------------------------------+ | "Total" | | | 20 | "basketballplayer:10, test:10" | "basketballplayer:30, test:30" | +-------------+------+----------+--------------+--------------------------------+--------------------------------+ ``` diff --git a/docs-2.0/3.ngql-guide/9.space-statements/3.show-spaces.md b/docs-2.0/3.ngql-guide/9.space-statements/3.show-spaces.md index aa9dbe3c100..fac20b85439 100644 --- a/docs-2.0/3.ngql-guide/9.space-statements/3.show-spaces.md +++ b/docs-2.0/3.ngql-guide/9.space-statements/3.show-spaces.md @@ -16,9 +16,8 @@ nebula> SHOW SPACES; | Name | +--------------------+ | "cba" | -+--------------------+ | "basketballplayer" | +--------------------+ ``` -创建图空间请参见[CREATE SPACE](1.create-space.md)。 \ No newline at end of file +创建图空间请参见[CREATE SPACE](1.create-space.md)。 diff --git a/docs-2.0/3.ngql-guide/9.space-statements/5.drop-space.md b/docs-2.0/3.ngql-guide/9.space-statements/5.drop-space.md index b2de05aaff8..789028d5327 100644 --- a/docs-2.0/3.ngql-guide/9.space-statements/5.drop-space.md +++ b/docs-2.0/3.ngql-guide/9.space-statements/5.drop-space.md @@ -12,7 +12,7 @@ DROP SPACE [IF EXISTS] ; ``` -`IF NOT EXISTS`关键字可以检测待删除的图空间是否存在,只有存在时,才会删除图空间。 +`IF EXISTS`关键字可以检测待删除的图空间是否存在,只有存在时,才会删除图空间。 `DROP SPACE`语句不会立刻删除硬盘上对应图空间的目录和文件,请使用`USE`语句指定其他任意图空间,然后执行`SUBMIT JOB COMPACT`。 diff --git a/docs-2.0/4.deployment-and-installation/1.resource-preparations.md b/docs-2.0/4.deployment-and-installation/1.resource-preparations.md index 1b6c3db5504..57ba69a4c65 100644 --- a/docs-2.0/4.deployment-and-installation/1.resource-preparations.md +++ b/docs-2.0/4.deployment-and-installation/1.resource-preparations.md @@ -114,22 +114,22 @@ 如果版本正确,用户可以跳过本小节。如果不正确,请根据如下步骤安装: - 1. 克隆仓库`nebula-common`到主机。 + 1. 克隆仓库`nebula`到主机。 ```bash - $ git clone -b v{{ nebula.release}} https://github.com/vesoft-inc/nebula-common.git + $ git clone -b {{ nebula.branch}} https://github.com/vesoft-inc/nebula.git ``` 如需安装特定版本的Nebula Graph,使用`--branch`或`-b`选项指定相应的nebula-common分支。 例如,指定{{ nebula.release }},命令如下: ```bash - $ git clone --branch v{{ nebula.release }} https://github.com/vesoft-inc/nebula-common.git + $ git clone --branch {{ nebula.branch}} https://github.com/vesoft-inc/nebula.git ``` - 2. 进入目录`nebula-common`。 + 2. 进入目录`nebula`。 ```bash - $ cd nebula-common + $ cd nebula ``` 3. 执行如下命令安装和启用GCC和CMake。 @@ -223,7 +223,7 @@ storaged进程的数量不会影响图空间副本的数量。 -用户可以在一台机器上部署多个进程,例如五台机器构成的集群,用户可以按照如下方案部署Nebula Graph。 +用户可以在一台机器上部署多个不同进程,例如五台机器构成的集群,用户可以按照如下方案部署Nebula Graph。 | 机器名称 | metad进程数量 | storaged进程数量 | graphd进程数量 | | ------------ | --------------- | ------------------ | ---------------- | diff --git a/docs-2.0/4.deployment-and-installation/2.compile-and-install-nebula-graph/1.install-nebula-graph-by-compiling-the-source-code.md b/docs-2.0/4.deployment-and-installation/2.compile-and-install-nebula-graph/1.install-nebula-graph-by-compiling-the-source-code.md index b397feda3b2..44b66c8f5a7 100644 --- a/docs-2.0/4.deployment-and-installation/2.compile-and-install-nebula-graph/1.install-nebula-graph-by-compiling-the-source-code.md +++ b/docs-2.0/4.deployment-and-installation/2.compile-and-install-nebula-graph/1.install-nebula-graph-by-compiling-the-source-code.md @@ -14,31 +14,35 @@ ## 安装步骤 +!!! Note + + 从{{ nebula.release }}版本开始,Nebula-Graph、Nebula-Storage、Nebula-Common的代码仓库合并为Nebula代码仓库,因此编译步骤与之前版本的步骤有所不同。 + 1. 克隆Nebula Graph的源代码到主机。 - - [推荐]如果需要安装v{{nebula.release}}版本的Nebula Graph,执行如下命令: + - [推荐]如果需要安装{{nebula.release}}版本的Nebula Graph,执行如下命令: - ```bash - $ git clone --branch v{{nebula.release}} https://github.com/vesoft-inc/nebula-graph.git - ``` + ```bash + $ git clone --branch {{nebula.branch}} https://github.com/vesoft-inc/nebula.git + ``` - - 如果需要安装最新的开发版本用于测试,执行如下命令克隆master分支的代码: + - 如果需要安装最新的开发版本用于测试,执行如下命令克隆master分支的代码: - ```bash - $ git clone https://github.com/vesoft-inc/nebula-graph.git - ``` + ```bash + $ git clone https://github.com/vesoft-inc/nebula.git + ``` -2. 进入目录`nebula-graph`。 +2. 进入目录`nebula`。 - ```bash - $ cd nebula-graph - ``` + ```bash + $ cd nebula + ``` 3. 创建目录`build`并进入该目录。 - ```bash - $ mkdir build && cd build - ``` + ```bash + $ mkdir build && cd build + ``` 4. 使用CMake生成makefile文件。 @@ -48,18 +52,9 @@ 更多CMake参数说明,请参见[CMake参数](#cmake)。 - - 如果在第1步下载了v{{nebula.release}}版本的源码,执行如下命令。选项`-DNEBULA_COMMON_REPO_TAG`和`-DNEBULA_STORAGE_REPO_TAG`用于指定[nebula-common](https://github.com/vesoft-inc/nebula-common)和[nebula-storage](https://github.com/vesoft-inc/nebula-storage)库的分支,以使各Nebula Graph组件的版本保持一致。 - - ```bash - $ cmake -DENABLE_BUILD_STORAGE=on -DENABLE_TESTING=OFF -DCMAKE_BUILD_TYPE=Release \ - -DNEBULA_COMMON_REPO_TAG=v{{ nebula.release }} -DNEBULA_STORAGE_REPO_TAG=v{{ nebula.release }} .. - ``` - - - 如果在第1步下载了master分支的代码,执行如下命令即可。 - - ```bash - $ cmake -DENABLE_BUILD_STORAGE=on -DENABLE_TESTING=OFF -DENABLE_MODULE_UPDATE=ON -DCMAKE_BUILD_TYPE=Release .. - ``` + ```bash + $ cmake -DCMAKE_INSTALL_PREFIX=/usr/local/nebula -DENABLE_TESTING=OFF -DCMAKE_BUILD_TYPE=Release .. + ``` 5. 编译Nebula Graph。 @@ -67,17 +62,17 @@ 检查[软硬件要求和安装三方库依赖包](../1.resource-preparations.md)。 - 为了适当地加快编译速度,可以使用选项`-j`并行编译。并行数量`N`建议为$\min(\text{CPU}核数,\frac{内存(GB)}{2})$。 + 为了适当地加快编译速度,可以使用选项`-j`并行编译。并行数量`N`建议为$\min(\text{CPU}核数,\frac{内存(GB)}{2})$。 - ```bash - $ make -j{N} # E.g., make -j2 - ``` + ```bash + $ make -j{N} # E.g., make -j2 + ``` 6. 安装Nebula Graph。 - ```bash - $ sudo make install-all - ``` + ```bash + $ sudo make install + ``` 7. 安装目录下的 `etc/` 目录中(默认为`/usr/local/nebula/etc`)的配置文件为参考模版,用户可以根据需要创建自己的配置文件。如果要使用 `script` 目录下的脚本,启动、停止、重启、中止和查看服务,配置文件需要命名为 `nebula-graph.conf`,`nebula-metad.conf`和`nebula-storaged.conf`。 @@ -89,11 +84,9 @@ master分支的代码更新速度快,如果安装了master分支对应的开发版Nebula Graph,可根据以下步骤更新版本。 - 1. 在目录`nebula-graph/`中,执行命令`git pull upstream master`更新源码。 +1. 在目录`nebula`中,执行命令`git pull upstream master`更新源码。 - 2. 在目录`nebula-graph/modules/common/`和`nebula-graph/modules/storage/`中,分别执行命令`git pull upstream master`。 - - 3. 在目录`nebula-graph/build/`中,重新执行`make -j{N}`和`make install-all`。 +2. 在目录`nebula/build`中,重新执行`make -j{N}`和`make install`。 ## 下一步 @@ -113,12 +106,6 @@ $ cmake -D= ... 下文的CMake参数可以在配置(CMake)阶段用来调整编译设置。 -### ENABLE_BUILD_STORAGE - -从{{ nebula.release }}版本开始,Nebula Graph的graph和storage代码仓库分离,可以各自单独编译。`ENABLE_BUILD_STORAGE`默认值为`OFF`,表示Storage服务不会和Graph服务一起安装。 - -如果单机部署Nebula Graph进行测试,可以设置`ENABLE_BUILD_STORAGE=ON`,安装时会自动下载和安装Storage服务。 - ### CMAKE_INSTALL_PREFIX `CMAKE_INSTALL_PREFIX`指定Nebula Graph服务模块、脚本和配置文件的安装路径,默认路径为`/usr/local/nebula`。 @@ -166,7 +153,7 @@ $ cmake -DCMAKE_C_COMPILER= -DCMAKE_CXX_COMPILER= -DCMAKE_CXX_COMPILER= nebula-console -u -p --address=graphd --port=9669 ``` - + !!! Note 默认情况下,身份认证功能是关闭的,只能使用已存在的用户名(默认为`root`)和任意密码登录。如果想使用身份认证,请参见[身份认证](../../7.data-security/1.authentication/1.authentication.md)。 @@ -98,11 +98,8 @@ | Host | Port | Status | Leader count | Leader distribution | Partition distribution | +-------------+------+----------+--------------+----------------------+------------------------+ | "storaged0" | 9779 | "ONLINE" | 0 | "No valid partition" | "No valid partition" | - +-------------+------+----------+--------------+----------------------+------------------------+ | "storaged1" | 9779 | "ONLINE" | 0 | "No valid partition" | "No valid partition" | - +-------------+------+----------+--------------+----------------------+------------------------+ | "storaged2" | 9779 | "ONLINE" | 0 | "No valid partition" | "No valid partition" | - +-------------+------+----------+--------------+----------------------+------------------------+ | "Total" | | | 0 | | | +-------------+------+----------+--------------+----------------------+------------------------+ ``` @@ -178,24 +175,24 @@ $ docker-compose down 如果返回如下信息,表示已经成功停止服务。 ```bash -Stopping nebula-docker-compose_storaged0_1 ... done +Stopping nebula-docker-compose_graphd2_1 ... done Stopping nebula-docker-compose_graphd1_1 ... done Stopping nebula-docker-compose_graphd_1 ... done Stopping nebula-docker-compose_storaged1_1 ... done -Stopping nebula-docker-compose_graphd2_1 ... done Stopping nebula-docker-compose_storaged2_1 ... done +Stopping nebula-docker-compose_storaged0_1 ... done Stopping nebula-docker-compose_metad0_1 ... done -Stopping nebula-docker-compose_metad2_1 ... done Stopping nebula-docker-compose_metad1_1 ... done -Removing nebula-docker-compose_storaged0_1 ... done +Stopping nebula-docker-compose_metad2_1 ... done +Removing nebula-docker-compose_graphd2_1 ... done Removing nebula-docker-compose_graphd1_1 ... done Removing nebula-docker-compose_graphd_1 ... done Removing nebula-docker-compose_storaged1_1 ... done -Removing nebula-docker-compose_graphd2_1 ... done Removing nebula-docker-compose_storaged2_1 ... done +Removing nebula-docker-compose_storaged0_1 ... done Removing nebula-docker-compose_metad0_1 ... done -Removing nebula-docker-compose_metad2_1 ... done Removing nebula-docker-compose_metad1_1 ... done +Removing nebula-docker-compose_metad2_1 ... done Removing network nebula-docker-compose_nebula-net ``` @@ -217,7 +214,7 @@ Docker Compose部署的Nebula Graph,配置文件位置为`nebula-docker-compos ```bash graphd: - image: vesoft/nebula-graphd:v2.5.0 + image: vesoft/nebula-graphd:{{nebula.branch}} ... ports: - 9669:9669 @@ -227,10 +224,19 @@ graphd: `9669:9669`表示内部的9669映射到外部的端口也是9669,下方的`19669`表示内部的19669映射到外部的端口是随机的。 -### 如何更新Nebula Graph服务的Docker镜像? +### 如何升级/更新Nebula Graph服务的Docker镜像? -在目录`nebula-docker-compose`内执行命令`docker-compose pull`,可以更新Graph服务、Storage服务和Meta服务的镜像。 +1. 在文件`nebula-docker-compose/docker-compose.yaml`中,找到所有服务的`image`并修改其值为相应的镜像版本。 + +2. 在目录`nebula-docker-compose`内执行命令`docker-compose pull`,更新Graph服务、Storage服务和Meta服务的镜像。 + + !!! note + 执行`docker-compose pull`命令更新服务镜像前,确保已停止Nebula Graph。 + +3. 执行命令`docker-compose up -d`启动Nebula Graph服务。 +4. 通过Nebula Console连接Nebula Graph后,分别执行命令`show hosts graph`、`show hosts storage`、`show hosts meta`查看各服务版本。 + ### 执行命令`docker-compose pull`报错`ERROR: toomanyrequests` 可能遇到如下错误: @@ -244,20 +250,9 @@ graphd: 执行如下命令可以更新Nebula Console客户端镜像。 ```bash -docker pull vesoft/nebula-console:v2.5.0 +docker pull vesoft/nebula-console:{{console.branch}} ``` -### 如何升级Nebula Graph? - -更新Nebula Graph的Docker镜像并重启服务: - -1. 在目录`nebula-docker-compose`内,执行命令`docker-compose pull`更新Nebula Graph的Docker镜像。 - -2. 执行命令`docker-compose down`停止Nebula Graph服务。 - -3. 执行命令`docker-compose up -d`启动Nebula Graph服务。 - - ### 为什么更新nebula-docker-compose仓库(Nebula Graph 2.0.0-RC)后,无法通过端口`3699`连接Nebula Graph? 在 Nebula Graph 2.0.0-RC 版本,默认端口从`3699`改为`9669`。请使用`9669`端口连接,或修改配置文件`docker-compose.yaml`内的端口。 diff --git a/docs-2.0/4.deployment-and-installation/2.compile-and-install-nebula-graph/4.install-nebula-graph-from-tar.md b/docs-2.0/4.deployment-and-installation/2.compile-and-install-nebula-graph/4.install-nebula-graph-from-tar.md new file mode 100644 index 00000000000..305a17dedd0 --- /dev/null +++ b/docs-2.0/4.deployment-and-installation/2.compile-and-install-nebula-graph/4.install-nebula-graph-from-tar.md @@ -0,0 +1,71 @@ +# 使用tar.gz文件安装Nebula Graph + +用户可以下载打包好的tar.gz文件快速安装Nebula Graph。 + +!!! note + + Nebula Graph从2.6.0版本起提供tar.gz文件。 + +## 操作步骤 + +1. 使用如下地址下载Nebula Graph的tar.gz文件。 + + 下载前需将``替换为需要下载的版本。 + + ```bash + //Centos 7 + https://oss-cdn.nebula-graph.com.cn/package//nebula-graph-.el7.x86_64.tar.gz + //Checksum + https://oss-cdn.nebula-graph.com.cn/package//nebula-graph-.el7.x86_64.tar.gz.sha256sum.txt + + //Centos 8 + https://oss-cdn.nebula-graph.com.cn/package//nebula-graph-.el8.x86_64.tar.gz + //Checksum + https://oss-cdn.nebula-graph.com.cn/package//nebula-graph-.el8.x86_64.tar.gz.sha256sum.txt + + //Ubuntu 1604 + https://oss-cdn.nebula-graph.com.cn/package//nebula-graph-.ubuntu1604.amd64.tar.gz + //Checksum + https://oss-cdn.nebula-graph.com.cn/package//nebula-graph-.ubuntu1604.amd64.tar.gz.sha256sum.txt + + //Ubuntu 1804 + https://oss-cdn.nebula-graph.com.cn/package//nebula-graph-.ubuntu1804.amd64.tar.gz + //Checksum + https://oss-cdn.nebula-graph.com.cn/package//nebula-graph-.ubuntu1804.amd64.tar.gz.sha256sum.txt + + //Ubuntu 2004 + https://oss-cdn.nebula-graph.com.cn/package//nebula-graph-.ubuntu2004.amd64.tar.gz + //Checksum + https://oss-cdn.nebula-graph.com.cn/package//nebula-graph-.ubuntu2004.amd64.tar.gz.sha256sum.txt + ``` + + 例如,要下载适用于`CentOS 7.5`的Nebula Graph {{nebula.branch}} tar.gz文件,运行以下命令: + + ```bash + wget https://oss-cdn.nebula-graph.com.cn/package/{{nebula.release}}/nebula-graph-{{nebula.release}}.el7.x86_64.tar.gz + ``` + +2. 解压tar.gz文件到Nebula Graph安装目录。 + + ```bash + tar -xvzf -C + ``` + + * `tar.gz_file_name`表示tar.gz文件的名称。 + * `install_path`表示安装路径。 + + 例如: + + ```bash + tar -xvzf nebula-graph-2.6.0.el7.x86_64.tar.gz -C /home/joe/nebula/install + ``` + +3. 修改配置文件名以应用配置。 + + 进入解压出的目录,将子目录`etc`中的文件`nebula-graphd.conf.default`、`nebula-metad.conf.default`和`nebula-storaged.conf.default`重命名,删除`.default`,即可应用Nebula Graph的默认配置。如需修改配置,参见[配置管理](../../5.configurations-and-logs/1.configurations/1.configurations.md)。 + +至此,Nebula Graph安装完毕。 + +## 下一步 + +使用`scripts`目录中的`nebula.service`文件启动Nebula Graph,详情参见[管理Nebula Graph服务](../manage-service.md)。 diff --git a/docs-2.0/4.deployment-and-installation/2.compile-and-install-nebula-graph/deploy-nebula-graph-cluster.md b/docs-2.0/4.deployment-and-installation/2.compile-and-install-nebula-graph/deploy-nebula-graph-cluster.md index da0e4ec8d29..fb68272c56f 100644 --- a/docs-2.0/4.deployment-and-installation/2.compile-and-install-nebula-graph/deploy-nebula-graph-cluster.md +++ b/docs-2.0/4.deployment-and-installation/2.compile-and-install-nebula-graph/deploy-nebula-graph-cluster.md @@ -1,4 +1,4 @@ -# 使用RPM/DEB包部署Nebula Graph集群 +# 使用RPM/DEB包部署Nebula Graph多机集群 Nebula Graph不提供官方的集群部署工具,用户可以使用RPM或DEB文件手动部署集群。本文提供了部署集群的示例。 @@ -71,7 +71,7 @@ Nebula Graph的所有配置文件均位于安装目录的`etc`目录内,包括 ``` - `nebula-storaged.conf` - + ```bash ########## networking ########## # Comma separated Meta server addresses @@ -256,9 +256,9 @@ Nebula Graph的所有配置文件均位于安装目录的`etc`目录内,包括 ### 3.启动集群 -依次启动各个服务器上的对应进程。说明如下。 +依次启动**各个服务器**上的对应进程。 -| 机器名称 |待启动的进程 | +| 机器名称 |待启动的进程 | | :----- |:---------------| | A | graphd、storaged、metad| | B | graphd、storaged、metad| @@ -274,7 +274,9 @@ sudo /usr/local/nebula/scripts/nebula.service start !!! note - - graphd、storaged和metad都启动时,可以用all代替。 + - 确保每个服务器中的对应进程都已启动,否则服务将启动失败。 + + - 当需都启动graphd、storaged和metad时,可以用all代替。 - `/usr/local/nebula`是Nebula Graph的默认安装路径,如果修改过安装路径,请使用实际路径。更多启停服务的内容,请参见[管理Nebula Graph服务](../../2.quick-start/5.start-stop-service.md)。 @@ -293,15 +295,10 @@ Welcome to Nebula Graph! | Host | Port | Status | Leader count | Leader distribution | Partition distribution | +------------------+------+----------+--------------+----------------------+------------------------+ | "192.168.10.111" | 9779 | "ONLINE" | 0 | "No valid partition" | "No valid partition" | -+------------------+------+----------+--------------+----------------------+------------------------+ | "192.168.10.112" | 9779 | "ONLINE" | 0 | "No valid partition" | "No valid partition" | -+------------------+------+----------+--------------+----------------------+------------------------+ | "192.168.10.113" | 9779 | "ONLINE" | 0 | "No valid partition" | "No valid partition" | -+------------------+------+----------+--------------+----------------------+------------------------+ | "192.168.10.114" | 9779 | "ONLINE" | 0 | "No valid partition" | "No valid partition" | -+------------------+------+----------+--------------+----------------------+------------------------+ | "192.168.10.115" | 9779 | "ONLINE" | 0 | "No valid partition" | "No valid partition" | -+------------------+------+----------+--------------+----------------------+------------------------+ | "Total" | | | 0 | | | +------------------+------+----------+--------------+----------------------+------------------------+ ``` diff --git a/docs-2.0/4.deployment-and-installation/3.upgrade-nebula-graph/upgrade-nebula-from-200-to-250.md b/docs-2.0/4.deployment-and-installation/3.upgrade-nebula-graph/upgrade-nebula-from-200-to-260.md similarity index 95% rename from docs-2.0/4.deployment-and-installation/3.upgrade-nebula-graph/upgrade-nebula-from-200-to-250.md rename to docs-2.0/4.deployment-and-installation/3.upgrade-nebula-graph/upgrade-nebula-from-200-to-260.md index f5494cd6cb4..599719c9ce5 100644 --- a/docs-2.0/4.deployment-and-installation/3.upgrade-nebula-graph/upgrade-nebula-from-200-to-250.md +++ b/docs-2.0/4.deployment-and-installation/3.upgrade-nebula-graph/upgrade-nebula-from-200-to-260.md @@ -4,7 +4,7 @@ Nebula Graph v2.0.x升级至v{{nebula.release}},只需要使用v{{nebula.relea !!! note - Nebula Graph v2.0.x指v2.0.0-GA和v2.0.1版本。如果Nebula Graph版本过低(v2.0.0-RC、v2.0.0-beta、v1.x),请参见[升级 Nebula Graph 历史版本至 v{{nebula.release}}](upgrade-nebula-graph-to-250.md)。 + Nebula Graph v2.0.x指v2.0.0-GA和v2.0.1版本。如果Nebula Graph版本过低(v2.0.0-RC、v2.0.0-beta、v1.x),请参见[升级 Nebula Graph 历史版本至 v{{nebula.release}}](upgrade-nebula-graph-to-260.md)。 ## RPM/DEB包升级步骤 @@ -45,7 +45,7 @@ Nebula Graph v2.0.x升级至v{{nebula.release}},只需要使用v{{nebula.relea ## Docker Compose部署升级步骤 -1. 修改目录`nebula-docker-compose`内的文件`docker-compose.yaml`,将`image`后的所有版本都修改为`{{nebula.release}}`。 +1. 修改目录`nebula-docker-compose`内的文件`docker-compose.yaml`,将`image`后的所有版本都修改为`{{nebula.branch}}`。 2. 在目录`nebula-docker-compose`内执行命令`docker-compose pull`,更新所有服务的镜像版本。 diff --git a/docs-2.0/4.deployment-and-installation/3.upgrade-nebula-graph/upgrade-nebula-graph-to-250.md b/docs-2.0/4.deployment-and-installation/3.upgrade-nebula-graph/upgrade-nebula-graph-to-260.md similarity index 95% rename from docs-2.0/4.deployment-and-installation/3.upgrade-nebula-graph/upgrade-nebula-graph-to-250.md rename to docs-2.0/4.deployment-and-installation/3.upgrade-nebula-graph/upgrade-nebula-graph-to-260.md index 36914a79d25..93d95d0e9f9 100644 --- a/docs-2.0/4.deployment-and-installation/3.upgrade-nebula-graph/upgrade-nebula-graph-to-250.md +++ b/docs-2.0/4.deployment-and-installation/3.upgrade-nebula-graph/upgrade-nebula-graph-to-260.md @@ -4,7 +4,7 @@ Nebula Graph历史版本指低于Nebula Graph v2.0.0-GA的版本,本文介绍 !!! note - Nebula Graph v2.0.0-GA或更新版本升级至v{{nebula.release}},请参见[Nebula Graph v2.0.x升级至v{{nebula.release}}](upgrade-nebula-from-200-to-250.md)。 + Nebula Graph v2.0.0-GA或更新版本升级至v{{nebula.release}},请参见[Nebula Graph v2.0.x升级至v{{nebula.release}}](upgrade-nebula-from-200-to-260.md)。 ## 升级限制 @@ -96,13 +96,13 @@ Nebula Graph历史版本指低于Nebula Graph v2.0.0-GA的版本,本文介绍 - clone 源代码 ``` - # git clone --branch v{{nebula.release}} https://github.com/vesoft-inc/nebula-graph.git + # git clone --branch {{nebula.branch}} https://github.com/vesoft-inc/nebula-graph.git ``` - 设置 CMake ``` - # cmake -DCMAKE_INSTALL_PREFIX=${nebula-new} -DENABLE_BUILD_STORAGE=on -DENABLE_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DNEBULA_COMMON_REPO_TAG=v{{nebula.release}} -DNEBULA_STORAGE_REPO_TAG=v{{nebula.release}} .. + # cmake -DCMAKE_INSTALL_PREFIX=${nebula-new} -DENABLE_TESTING=OFF -DCMAKE_BUILD_TYPE=Release .. ``` 2. 拷贝配置文件。 @@ -273,7 +273,7 @@ Nebula Graph历史版本指低于Nebula Graph v2.0.0-GA的版本,本文介绍 11. 升级其他客户端。 - 所有的客户端都必须升级到支持Nebula Graph v{{nebula.release}} 的版本。包括但不限于[Python](https://github.com/vesoft-inc/nebula-python)、[Java](https://github.com/vesoft-inc/nebula-java)、[go](https://github.com/vesoft-inc/nebula-go)、[C++](https://github.com/vesoft-inc/nebula-cpp)、[Flink-connector](https://github.com/vesoft-inc/nebula-flink-connector)、[Spark-util](https://github.com/vesoft-inc/nebula-spark-utils)、[Nebula Bench](https://github.com/vesoft-inc/nebula-bench)。请找到各 repo 对应的 branch。 + 所有的客户端都必须升级到支持Nebula Graph v{{nebula.release}} 的版本。包括但不限于[Python](https://github.com/vesoft-inc/nebula-python)、[Java](https://github.com/vesoft-inc/nebula-java)、[go](https://github.com/vesoft-inc/nebula-go)、[C++](https://github.com/vesoft-inc/nebula-cpp)、[Flink-connector](https://github.com/vesoft-inc/nebula-flink-connector)、[Algorithm](https://github.com/vesoft-inc/nebula-algorithm)、[Exchange](https://github.com/vesoft-inc/nebula-exchange)、[Spark-connector](https://github.com/vesoft-inc/nebula-spark-connector)、[Nebula Bench](https://github.com/vesoft-inc/nebula-bench)。请找到各 repo 对应的 branch。 !!! Note diff --git a/docs-2.0/4.deployment-and-installation/6.deploy-text-based-index/1.text-based-index-restrictions.md b/docs-2.0/4.deployment-and-installation/6.deploy-text-based-index/1.text-based-index-restrictions.md index d3f70df4326..b7c817d4f47 100644 --- a/docs-2.0/4.deployment-and-installation/6.deploy-text-based-index/1.text-based-index-restrictions.md +++ b/docs-2.0/4.deployment-and-installation/6.deploy-text-based-index/1.text-based-index-restrictions.md @@ -35,3 +35,5 @@ - 在点或边的属性值中不要包含`'`或 `\`,否则会导致Elasticsearch集群存储时报错。 - 从写入Nebula Graph,到写入listener,再到写入 Elasticsearch 并创建索引可能需要一段时间。如果访问全文索引时返回未找到索引,可等待索引生效(但是,该等待时间未知,也无返回码检查)。 + +- 使用K8s方式部署的Nebula Graph集群不支持全文索引。 diff --git a/docs-2.0/4.deployment-and-installation/6.deploy-text-based-index/2.deploy-es.md b/docs-2.0/4.deployment-and-installation/6.deploy-text-based-index/2.deploy-es.md index 82e929e3daf..85e0053f612 100644 --- a/docs-2.0/4.deployment-and-installation/6.deploy-text-based-index/2.deploy-es.md +++ b/docs-2.0/4.deployment-and-installation/6.deploy-text-based-index/2.deploy-es.md @@ -8,7 +8,7 @@ Nebula Graph的全文索引是基于[Elasticsearch](https://en.wikipedia.org/wik ## 部署Elasticsearch集群 -部署Elasticsearch集群请参见[Kubernetes安装Elasticsearch](https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-deploy-elasticsearch.html)或[单机安装Elasticsearch](https://www.elastic.co/guide/en/elasticsearch/reference/6.0/_installation.html)。 +部署Elasticsearch集群请参见[Kubernetes安装Elasticsearch](https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-deploy-elasticsearch.html)或[单机安装Elasticsearch](https://www.elastic.co/guide/en/elasticsearch/reference/7.15/targz.html)。 当Elasticsearch集群启动时,请添加Nebula Graph全文索引的模板文件。关于索引模板的说明请参见[Elasticsearch官方文档](https://www.elastic.co/guide/en/elasticsearch/reference/current/index-templates.html)。 @@ -108,9 +108,7 @@ nebula> SHOW TEXT SEARCH CLIENTS; | Host | Port | +-------------+------+ | "127.0.0.1" | 9200 | -+-------------+------+ | "127.0.0.1" | 9200 | -+-------------+------+ | "127.0.0.1" | 9200 | +-------------+------+ ``` diff --git a/docs-2.0/4.deployment-and-installation/6.deploy-text-based-index/3.deploy-listener.md b/docs-2.0/4.deployment-and-installation/6.deploy-text-based-index/3.deploy-listener.md index 2b3145651f5..aa0771c34cc 100644 --- a/docs-2.0/4.deployment-and-installation/6.deploy-text-based-index/3.deploy-listener.md +++ b/docs-2.0/4.deployment-and-installation/6.deploy-text-based-index/3.deploy-listener.md @@ -90,9 +90,7 @@ nebula> SHOW LISTENER; | PartId | Type | Host | Status | +--------+-----------------+-----------------------+----------+ | 1 | "ELASTICSEARCH" | "[192.168.8.5:46780]" | "ONLINE" | -+--------+-----------------+-----------------------+----------+ | 2 | "ELASTICSEARCH" | "[192.168.8.5:46780]" | "ONLINE" | -+--------+-----------------+-----------------------+----------+ | 3 | "ELASTICSEARCH" | "[192.168.8.5:46780]" | "ONLINE" | +--------+-----------------+-----------------------+----------+ ``` diff --git a/docs-2.0/5.configurations-and-logs/1.configurations/2.meta-config.md b/docs-2.0/5.configurations-and-logs/1.configurations/2.meta-config.md index d924b4376fa..699b7a02dce 100644 --- a/docs-2.0/5.configurations-and-logs/1.configurations/2.meta-config.md +++ b/docs-2.0/5.configurations-and-logs/1.configurations/2.meta-config.md @@ -24,8 +24,6 @@ Meta服务提供了两份初始配置文件`nebula-metad.conf.default`和`nebula | `daemonize` | `true` | 是否启动守护进程。 | | `pid_file` | `pids/nebula-metad.pid` | 记录进程ID的文件。 | | `timezone_name` | - | 指定Nebula Graph的时区。初始配置文件中未设置该参数,如需使用请手动添加。系统默认值为`UTC+00:00:00`。格式请参见[Specifying the Time Zone with TZ](https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html "Click to view the timezone-related content in the GNU C Library manual")。例如,东八区的设置方式为`--timezone_name=UTC+08:00`。 | -| `local_config` | `true` | 是否从配置文件获取配置信息。 | -|`minimum_reserved_bytes`|-|每个数据存储路径的剩余空间最小值,低于该值时,可能会导致集群元数据操作失败。单位:字节。默认为`1073741824`,即1GB。| !!! Note diff --git a/docs-2.0/5.configurations-and-logs/1.configurations/3.graph-config.md b/docs-2.0/5.configurations-and-logs/1.configurations/3.graph-config.md index 39ab4f26e36..01fe6993775 100644 --- a/docs-2.0/5.configurations-and-logs/1.configurations/3.graph-config.md +++ b/docs-2.0/5.configurations-and-logs/1.configurations/3.graph-config.md @@ -24,7 +24,6 @@ Graph服务提供了两份初始配置文件`nebula-graphd.conf.default`和`nebu | `daemonize` | `true` | 是否启动守护进程。 | | `pid_file` | `pids/nebula-graphd.pid`| 记录进程ID的文件。 | |`enable_optimizer` |`true` | 是否启用优化器。| -| `system_memory_high_watermark_ratio` | - |内存高水位报警机制的触发阈值,默认为`0.8`。系统内存占用率高于该值会触发报警机制,Nebula Graph会停止接受查询。初始配置文件中未设置该参数,使用需手动添加。| | `timezone_name` | - | 指定Nebula Graph的时区。初始配置文件中未设置该参数,使用需手动添加。系统默认值为`UTC+00:00:00`。格式请参见[Specifying the Time Zone with TZ](https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html "Click to view the timezone-related content in the GNU C Library manual")。例如,东八区的设置方式为`--timezone_name=UTC+08:00`。 | | `local_config` | `true` | 是否从配置文件获取配置信息。 | @@ -52,6 +51,7 @@ Graph服务提供了两份初始配置文件`nebula-graphd.conf.default`和`nebu | ------------------- | ------------------------ | ------------------------------------------ | |`accept_partial_success` |`false` |是否将部分成功视为错误。此配置仅适用于只读请求,写请求总是将部分成功视为错误。| |`session_reclaim_interval_secs`|`10`| 将Session信息发送给Meta服务的间隔。单位:秒。| +|`max_allowed_query_size`|`4194304`|最大查询语句长度。单位:字节。默认为`4194304`,即4MB。| ## networking配置 @@ -92,3 +92,21 @@ Graph服务提供了两份初始配置文件`nebula-graphd.conf.default`和`nebu | ------------------- | ---------------- | ------------------------------------------ | |`enable_authorize` |`false` |用户登录时是否进行身份验证。身份验证详情请参见[身份验证](../../7.data-security/1.authentication/1.authentication.md)。| |`auth_type` |`password` |用户登录的身份验证方式。取值为`password`、`ldap`、`cloud`。| + +## memory配置 + +| 名称 | 预设值 | 说明 | +| ------------------- | ------------------------ | ------------------------------------------ | +| `system_memory_high_watermark_ratio` | - |内存高水位报警机制的触发阈值,默认为`0.9`。系统内存占用率高于该值会触发报警机制,Nebula Graph会停止接受查询。| + +## experimental配置 + +| 名称 | 预设值 | 说明 | +| ------------------- | ------------------------ | ------------------------------------------ | +|`enable_experimental_feature`|`false`|实验性功能开关。可选值为`true`和`false`。当前支持的实验性功能请参见下文。| + +### experimental功能说明 + +| 名称 | 说明 | +| ------------------- | ------------------------------------------| +|TOSS | TOSS(Transaction on Storage Side)功能,用于保证对边进行`INSERT`、`UPDATE`或`UPSERT`操作的最终一致性(因为逻辑上的一条边对应着硬盘上的两个键值对)。暂不支持`DELETE`操作。开启后会增加相关操作的时延约1倍。| diff --git a/docs-2.0/5.configurations-and-logs/1.configurations/4.storage-config.md b/docs-2.0/5.configurations-and-logs/1.configurations/4.storage-config.md index ed3b9560a7d..b457ae9e245 100644 --- a/docs-2.0/5.configurations-and-logs/1.configurations/4.storage-config.md +++ b/docs-2.0/5.configurations-and-logs/1.configurations/4.storage-config.md @@ -13,7 +13,7 @@ Storage服务提供了两份初始配置文件`nebula-storaged.conf.default`和` ## 配置文件参数值说明 -配置文件内没有设置某个参数表示参数使用的是默认值。文件内只预设了部分参数的值,而且两份初始配置文件内的参数值也略有不同,本文的预设值以`nebula-metad.conf.default`为准。 +配置文件内没有设置某个参数表示参数使用的是默认值。文件内只预设了部分参数的值,而且两份初始配置文件内的参数值也略有不同,本文的预设值以`nebula-metad.conf.default`文件为准,其中没有的参数则以`nebula-storaged.conf.production`文件为准。 !!! Note @@ -85,11 +85,24 @@ Storage服务提供了两份初始配置文件`nebula-storaged.conf.default`和` |`rocksdb_compression_per_level` | - | 为不同级别设置不同的压缩算法。 | |`enable_rocksdb_statistics` | `false` | 是否启用RocksDB的数据统计。 | |`rocksdb_stats_level` | `kExceptHistogramOrTimers` | RocksDB的数据统计级别。可选值为`kExceptHistogramOrTimers`(禁用计时器统计,跳过柱状图统计)、`kExceptTimers`(跳过计时器统计)、`kExceptDetailedTimers`(收集除互斥锁和压缩花费时间之外的所有统计数据)、`kExceptTimeForMutex`收集除互斥锁花费时间之外的所有统计数据)和`kAll`(收集所有统计数据)。 | -|`enable_rocksdb_prefix_filtering` | `false` | 是否启用prefix bloom filter (内存充裕时可以打开,提升图遍历速度)。 | -|`enable_rocksdb_whole_key_filtering` | `true` | 是否启用whole key bloom filter。 | +|`enable_rocksdb_prefix_filtering` | `true` | 是否启用prefix bloom filter,启用时可以提升图遍历速度,但是会增加内存消耗。 | +|`enable_rocksdb_whole_key_filtering` | `false` | 是否启用whole key bloom filter。 | |`rocksdb_filtering_prefix_length` | `12` | 每个key的prefix长度。可选值为`12`(分片ID+点ID)和`16`(分片ID+点ID+TagID/Edge typeID)。单位:字节。 | |`enable_partitioned_index_filter`|- |设置为`true`可以降低bloom过滤器占用的内存大小,但是在某些随机寻道(random-seek)的情况下,可能会降低读取性能。| +## misc配置 + +!!! caution + + 下表中的`snapshot`与Nebula Graph快照是不同的概念,这里的`snapshot`指Raft同步过程中leader上的存量数据。 + +| 名称 | 预设值 | 说明 | +| :-- | :----- | :--- | +| `snapshot_part_rate_limit` | `8388608` | Raft leader向Raft group中其它成员同步存量数据时的限速。单位:字节/秒。 | +| `snapshot_batch_size` | `1048576` | Raft leader向Raft group中其它成员同步存量数据时每批发送的数据量。单位:字节。 | +| `rebuild_index_part_rate_limit` | `4194304` | 重建索引过程中,Raft leader向Raft group中其它成员同步索引数据时的限速。单位:字节/秒。 | +| `rebuild_index_batch_size` | `1048576` | 重建索引过程中,Raft leader向Raft group中其它成员同步索引数据时每批发送的数据量。单位:字节。 | + ## rocksdb options配置 | 名称 | 预设值 | 说明 | diff --git a/docs-2.0/6.monitor-and-metrics/2.rocksdb-statistics.md b/docs-2.0/6.monitor-and-metrics/2.rocksdb-statistics.md index 4d118ac4e1d..05641d1db97 100644 --- a/docs-2.0/6.monitor-and-metrics/2.rocksdb-statistics.md +++ b/docs-2.0/6.monitor-and-metrics/2.rocksdb-statistics.md @@ -6,7 +6,7 @@ Nebula Graph 使用 RocksDB 作为底层存储,本文介绍如何收集和展 RocksDB 统计功能默认关闭,启动 RocksDB 统计功能,你需要: -1. 修改 `storaged.conf` 文件中 `--enable_rocksdb_statistics` 参数为 `true`。配置默认文件目录为 `/use/local/nebula/etc`。 +1. 修改 `nebula-storaged.conf` 文件中 `--enable_rocksdb_statistics` 参数为 `true`。配置默认文件目录为 `/use/local/nebula/etc`。 2. 重启服务使修改生效。 @@ -49,12 +49,19 @@ rocksdb.bytes.read=1632 使用以下命令获取部分 JSON 格式的 RocksDB 统计信息: ```bash -curl -L "http://${storage_ip}:${port}/rocksdb_stats?stats=${stats_name}.&returnjson" +curl -L "http://${storage_ip}:${port}/rocksdb_stats?stats=${stats_name}&format=json" ``` 例如使用以下语句获取 `rocksdb.bytes.read` 和 `rocksdb.block.cache.add`的统计信息并返回 JSON 的格式数据。 ```bash -curl -L "http://172.28.2.1:19779/rocksdb_stats?stats=rocksdb.bytes.read,rocksdb.block.cache.add&returnjson" - -[{"value":14,"name":rocksdb.block.cache.add},{"value":1632,"name":"rocksdb.bytes.read"}] +curl -L "http://172.28.2.1:19779/rocksdb_stats?stats=rocksdb.bytes.read,rocksdb.block.cache.add&format=json" + +[ + { + "rocksdb.block.cache.add": 1 + }, + { + "rocksdb.bytes.read": 160 + } +] ``` diff --git a/docs-2.0/7.data-security/1.authentication/2.management-user.md b/docs-2.0/7.data-security/1.authentication/2.management-user.md index 646a186ba67..04b62ec2d79 100644 --- a/docs-2.0/7.data-security/1.authentication/2.management-user.md +++ b/docs-2.0/7.data-security/1.authentication/2.management-user.md @@ -149,9 +149,7 @@ | Account | +-----------+ | "test1" | - +-----------+ | "test2" | - +-----------+ | "test3" | +-----------+ ``` diff --git a/docs-2.0/7.data-security/1.authentication/3.role-list.md b/docs-2.0/7.data-security/1.authentication/3.role-list.md index 59f339c8c3e..4da1a0fb450 100644 --- a/docs-2.0/7.data-security/1.authentication/3.role-list.md +++ b/docs-2.0/7.data-security/1.authentication/3.role-list.md @@ -57,7 +57,7 @@ Nebula Graph内置了多种角色,说明如下: |权限|God |Admin|DBA|User|Guest|相关语句| |:---|:---|:---|:---|:---|:---|:---| |Read space|Y|Y|Y|Y|Y|`USE`、`DESCRIBE SPACE`| - |Write space|Y|||||`CREATE SPACE`、`DROP SPACE`、`CREATE SNAPSHOT`、`DROP SNAPSHOT`、`BALANCE DATA`、`BALANCE DATA STOP`、`BALANCE DATA REMOVE`、`BALANCE LEADER`、`ADMIN`、`CONFIG`、`INGEST`、`DOWNLOAD`、`SUBMIT JOB COMPACT`、`SUBMIT JOB FLUSH`、`SUBMIT JOB STATS`、`STOP JOB`、`RECOVER JOB`、`BUILD TAG INDEX`、`BUILD EDGE INDEX`| + |Write space|Y|||||`CREATE SPACE`、`DROP SPACE`、`CREATE SNAPSHOT`、`DROP SNAPSHOT`、`BALANCE DATA`、`BALANCE DATA STOP`、`BALANCE DATA REMOVE`、`BALANCE LEADER`、`ADMIN`、`CONFIG`、`INGEST`、`DOWNLOAD`、`BUILD TAG INDEX`、`BUILD EDGE INDEX`| |Read schema|Y|Y|Y|Y|Y|`DESCRIBE TAG`、`DESCRIBE EDGE`、`DESCRIBE TAG INDEX`、`DESCRIBE EDGE INDEX`| |Write schema|Y|Y|Y|||`CREATE TAG`、`ALTER TAG`、`CREATE EDGE`、`ALTER EDGE`、`DROP TAG`、`DROP EDGE`、`CREATE TAG INDEX`、`CREATE EDGE INDEX`、`DROP TAG INDEX`、`DROP EDGE INDEX`| |Write user|Y|||||`CREATE USER`、`DROP USER`、`ALTER USER`| diff --git a/docs-2.0/7.data-security/1.authentication/4.ldap.md b/docs-2.0/7.data-security/1.authentication/4.ldap.md index 6f094f65368..8b77bb8b81f 100644 --- a/docs-2.0/7.data-security/1.authentication/4.ldap.md +++ b/docs-2.0/7.data-security/1.authentication/4.ldap.md @@ -82,7 +82,7 @@ OpenLDAP支持的认证方式有两种:简单绑定认证和搜索绑定认证 # OpenLDAP中的Schema名称 --ldap_scheme=ldap # 绑定目标对象的DN - --ldap_basedn=uid=test2,ou=it,dc=sys,dc=com + --ldap_basedn=ou=it,dc=sys,dc=com ``` 3. [重启Nebula Graph服务](../../4.deployment-and-installation/manage-service.md),让新配置生效。 diff --git a/docs-2.0/7.data-security/3.manage-snapshot.md b/docs-2.0/7.data-security/3.manage-snapshot.md index 68e04839cef..5988dedf0d7 100644 --- a/docs-2.0/7.data-security/3.manage-snapshot.md +++ b/docs-2.0/7.data-security/3.manage-snapshot.md @@ -54,7 +54,6 @@ nebula> SHOW SNAPSHOTS; | Name | Status | Hosts | +--------------------------------+---------+------------------+ | "SNAPSHOT_2021_03_09_08_43_12" | "VALID" | "127.0.0.1:9779" | -+--------------------------------+---------+------------------+ | "SNAPSHOT_2021_03_09_09_10_52" | "VALID" | "127.0.0.1:9779" | +--------------------------------+---------+------------------+ ``` diff --git a/docs-2.0/7.data-security/4.ssl.md b/docs-2.0/7.data-security/4.ssl.md new file mode 100644 index 00000000000..c18d29b02ee --- /dev/null +++ b/docs-2.0/7.data-security/4.ssl.md @@ -0,0 +1,64 @@ +# SSL加密 + +Nebula Graph支持在客户端、Graph服务、Meta服务和Storage服务之间进行SSL加密传输,本文介绍如何设置SSL加密。 + +## 注意事项 + +开启SSL加密会轻微影响性能。 + +## 参数介绍 + +| 参数 | 默认值 | 说明 | +| ---------------- | ------- | ------------------------------| +| `cert_path` | - | PEM证书的路径。 | +| `key_path` | - | 密钥证书的路径。 | +| `password_path` | - | 密码文件证书的路径。 | +| `ca_path` | - | 受信任CA证书文件的路径。 | +| `enable_ssl` | `false` | 是否开启SSL加密。 | +| `enable_graph_ssl` | `false` | 是否仅在Graph服务上开启SSL加密。 | +| `enable_meta_ssl` | `false` | 是否仅在Meta服务上开启SSL加密。 | + +## 证书模式 + +为了使用SSL加密,必须有SSL证书。Nebula Graph支持两种证书模式: + +- 自签名证书模式 + + 需要自行制作签名证书。需要根据加密策略,在对应的配置文件内设置`cert_path`、`key_path`和`password_path`。 + +- CA签名证书模式 + + 需要在认证机构(Certificate Authority)申请签名证书。需要根据加密策略,在对应的配置文件内设置`cert_path`、`key_path`和`ca_path`。 + +## 加密策略 + +Nebula Graph支持三种加密策略。加密涉及的具体进程请参见[详细说明](https://github.com/vesoft-inc/nebula/blob/a67d166b284cae1b534bf8d19c936ee38bf12e29/docs/rfcs/0001-ssl-transportation.md#usage-explanation)。 + +- 对客户端、Graph服务、Meta服务和Storage服务之间的传输数据加密。 + + 需要修改`nebula-graphd.conf`、`nebula-metad.conf`和`nebula-storaged.conf`配置文件,设置`enable_ssl = true`。 + +- 对客户端和Graph服务之间的传输数据加密。 + + 适用于集群设置在同一个机房内,仅对外开放Graph服务的端口。因为其他服务可以通过内部网络通信,无需加密。需要修改`nebula-graphd.conf`配置文件,设置`enable_graph_ssl = true`。 + +- 对集群中Meta服务相关的传输数据加密。 + + 适用于向meta服务传输需保密的信息。需要修改`nebula-graphd.conf`、`nebula-metad.conf`和`nebula-storaged.conf`配置文件,设置`enable_meta_ssl = true`。 + +## 使用方式 + +1. 确认证书模式和加密策略。 + +2. 在对应的配置文件内增加证书配置和策略配置。 + + 例如使用自签名证书,并对客户端、Graph服务、Meta服务和Storage服务之间的数据传输进行加密。需要对三个配置文件都进行如下设置: + + ```bash + --cert_path=xxxxxx + --key_path=xxxxx + --password_path=xxxxxx + --enable_ssl=true + ``` + +3. 客户端设置安全套接字并添加受信任的CA。示例代码请参见[nebula-test-run.py](https://github.com/vesoft-inc/nebula/blob/{{nebula.branch}}/tests/nebula-test-run.py)。 diff --git a/docs-2.0/7.data-security/5.zone.md b/docs-2.0/7.data-security/5.zone.md new file mode 100644 index 00000000000..2a40391d06b --- /dev/null +++ b/docs-2.0/7.data-security/5.zone.md @@ -0,0 +1,173 @@ +# Group&Zone + +Nebula Graph提供Group&Zone功能,可以将Storage节点进行分组管理,实现资源隔离。 + +## 背景信息 + +用户可以将Storage节点加入某个Zone中,多个Zone构成一个Group。创建图空间时指定Group,就会在Group内的Storage节点上创建及存储图空间。分片及其副本会均匀存储在各个Zone中。如下图所示。 + +![Group&Zone示意图](zone1.png) + +8台启动Storage服务的机器两两组合,加入4个Zone。然后将Zone1、Zone2、Zone3加入Group1,Zone3、Zone4加入Group2。 + +指定Group1创建图空间S1,分片及其副本会均匀存储在Zone1~Zone3,不会存储到Zone4的机器上。 + +指定Group2创建图空间S2,分片及其副本会均匀存储在Zone3~Zone4。不会存储到Zone1和Zone2的机器上。 + +上述例子简单介绍了Zone功能,用户可以通过合理规划Zone和Group,实现资源隔离。 + +## 适用场景 + +- 期望将图空间创建在某些指定的Storage节点上,从而达到资源隔离的目的。 + +- 集群滚动升级。需要停止一个或多个服务器并更新,然后重新投入使用,直到集群中所有的节点都更新为新版本。 + +## 注意事项 + +- Zone是Storage节点的集合,每个Storage节点只能加入一个Zone。 + +- Zone中可以存储分片的副本,但同一个分片在一个Zone中只能有一个副本。 + +- 多个Zone可以组成一个Group,方便管理,并且可以进行资源隔离。 + +- 一个Zone可以加入多个Group。 + +- 创建Space时如果指定Group,该图空间的副本将均匀分布在该Group的各个Zone中。 + +- 一个Group可以创建多个图空间,但是Group中Zone的数量需要大于等于创建图空间时指定的副本数(`replica_factor`)。 + +## 基本语法 + +### ADD ZONE + +创建Zone,并将Storage节点加入Zone。 + +```ngql +ADD ZONE : [,:...]; +``` + +示例: + +```ngql +nebula> ADD ZONE zone1 192.168.8.111:9779, 192.168.8.129:9779; +``` + +### ADD HOST...INTO ZONE + +将单个Storage节点加入已创建的Zone。 + +!!! note + + 加入之后请使用[BALANCE](../3.ngql-guide/18.operation-and-maintenance-statements/2.balance-syntax.md)命令实现负载均衡。 + +```ngql +ADD HOST : INTO ZONE ; +``` + +### DROP HOST...FROM ZONE + +从Zone中删除单个Storage节点。 + +!!! note + + Group中正在使用的Storage节点无法直接删除,需要先删除关联的图空间,才能删除Storage节点。 + +```ngql +DROP HOST : FROM ZONE ; +``` + +### SHOW ZONES + +查看所有Zone。 + +```ngql +SHOW ZONES; +``` + +### DESCRIBE ZONE + +查看指定Zone。 + +```ngql +DESCRIBE ZONE ; +DESC ZONE ; +``` + +### DROP ZONE + +删除Zone。 + +!!! note + + 已加入Group的Zone无法直接删除,需要先从Group中剔除该Zone,或删除所属的Group后,才能删除Zone。 + +```ngql +DROP ZONE ; +``` + +### ADD GROUP + +创建Group,并将Zone加入Group。 + +```ngql +ADD GROUP [,...]; +``` + +示例: + +```ngql +nebula> ADD GROUP group1 zone1,zone2; +``` + +### ADD ZONE...INTO GROUP + +将单个Zone加入已创建的Group。 + +!!! note + + 加入之后请使用[BALANCE](../3.ngql-guide/18.operation-and-maintenance-statements/2.balance-syntax.md)命令实现负载均衡。 + +```ngql +ADD ZONE INTO GROUP ; +``` + +### DROP ZONE...FROM GROUP + +从GROUP中删除单个Zone。 + +!!! note + + Group中正在使用的Zone无法直接删除,需要先删除关联的图空间,才能删除Zone。 + +```ngql +DROP ZONE FROM GROUP ; +``` + +### SHOW GROUPS + +查看所有Group。 + +```ngql +SHOW GROUPS; +``` + +### DESCRIBE GROUP + +查看指定Group。 + +```ngql +DESCRIBE GROUP ; +DESC GROUP ; +``` + +### DROP GROUP + +删除Group。 + +!!! note + + 正在使用的Group无法直接删除,需要先删除关联的图空间,才能删除Group。 + +```ngql +DROP GROUP ; +``` diff --git a/docs-2.0/7.data-security/zone1.png b/docs-2.0/7.data-security/zone1.png new file mode 100644 index 00000000000..b801b19459f Binary files /dev/null and b/docs-2.0/7.data-security/zone1.png differ diff --git a/docs-2.0/8.service-tuning/compaction.md b/docs-2.0/8.service-tuning/compaction.md index e685245de8e..abc383c8d0c 100644 --- a/docs-2.0/8.service-tuning/compaction.md +++ b/docs-2.0/8.service-tuning/compaction.md @@ -32,9 +32,7 @@ nebula> SHOW CONFIGS STORAGE; | module | name | type | mode | value | +-----------+-------------------------------------+-------+-----------+------------------------------------------------------------------------------------------------------+ | "STORAGE" | "v" | "int" | "MUTABLE" | 0 | -+-----------+-------------------------------------+-------+-----------+------------------------------------------------------------------------------------------------------+ ... -+-----------+-------------------------------------+-------+-----------+------------------------------------------------------------------------------------------------------+ | "STORAGE" | "rocksdb_column_family_options" | "map" | "MUTABLE" | {max_bytes_for_level_base: "268435456", max_write_buffer_number: "4", write_buffer_size: "67108864"} | +-----------+-------------------------------------+-------+-----------+------------------------------------------------------------------------------------------------------+ ... @@ -48,9 +46,7 @@ nebula> SHOW CONFIGS STORAGE; | module | name | type | mode | value | +-----------+-------------------------------------+-------+-----------+--------------------------------------------------------------------------------------------------------------------------------------+ | "STORAGE" | "v" | "int" | "MUTABLE" | 0 | -+-----------+-------------------------------------+-------+-----------+--------------------------------------------------------------------------------------------------------------------------------------+ ... -+-----------+-------------------------------------+-------+-----------+--------------------------------------------------------------------------------------------------------------------------------------+ | "STORAGE" | "rocksdb_column_family_options" | "map" | "MUTABLE" | {disable_auto_compactions: true, max_bytes_for_level_base: "268435456", max_write_buffer_number: "4", write_buffer_size: "67108864"} | +-----------+-------------------------------------+-------+-----------+--------------------------------------------------------------------------------------------------------------------------------------+ ... diff --git a/docs-2.0/8.service-tuning/improve-query-by-tag-index.md b/docs-2.0/8.service-tuning/improve-query-by-tag-index.md index be7e730d597..f64ecc07d82 100644 --- a/docs-2.0/8.service-tuning/improve-query-by-tag-index.md +++ b/docs-2.0/8.service-tuning/improve-query-by-tag-index.md @@ -27,7 +27,6 @@ nebula> MATCH (v:shareholder) RETURN v; | v | +---------------------------------------------------------------------+ | ("player100" :player{age: 42, name: "Tim Duncan"} :shareholder{}) | -+---------------------------------------------------------------------+ | ("player101" :player{age: 36, name: "Tony Parker"} :shareholder{}) | +---------------------------------------------------------------------+ nebula> LOOKUP ON shareholder; @@ -35,7 +34,6 @@ nebula> LOOKUP ON shareholder; | VertexID | +-------------+ | "player100" | -+-------------+ | "player101" | +-------------+ diff --git a/docs-2.0/8.service-tuning/load-balance.md b/docs-2.0/8.service-tuning/load-balance.md index 5860155b496..0d8786d322d 100644 --- a/docs-2.0/8.service-tuning/load-balance.md +++ b/docs-2.0/8.service-tuning/load-balance.md @@ -22,15 +22,10 @@ | Host | Port | Status | Leader count | Leader distribution | Partition distribution | +-------------+------+----------+--------------+-----------------------------------+------------------------+ | "storaged0" | 9779 | "ONLINE" | 4 | "basketballplayer:4" | "basketballplayer:15" | - +-------------+------+----------+--------------+-----------------------------------+------------------------+ | "storaged1" | 9779 | "ONLINE" | 8 | "basketballplayer:8" | "basketballplayer:15" | - +-------------+------+----------+--------------+-----------------------------------+------------------------+ | "storaged2" | 9779 | "ONLINE" | 3 | "basketballplayer:3" | "basketballplayer:15" | - +-------------+------+----------+--------------+-----------------------------------+------------------------+ | "storaged3" | 9779 | "ONLINE" | 0 | "No valid partition" | "No valid partition" | - +-------------+------+----------+--------------+-----------------------------------+------------------------+ | "storaged4" | 9779 | "ONLINE" | 0 | "No valid partition" | "No valid partition" | - +-------------+------+----------+--------------+-----------------------------------+------------------------+ | "Total" | | | 15 | "basketballplayer:15" | "basketballplayer:45" | +-------------+------+----------+--------------+-----------------------------------+------------------------+ ``` @@ -54,13 +49,9 @@ | balanceId, spaceId:partId, src->dst | status | +--------------------------------------------------------------+-------------------+ | "[1614237867, 11:1, storaged1:9779->storaged3:9779]" | "SUCCEEDED" | - +--------------------------------------------------------------+-------------------+ | "[1614237867, 11:1, storaged2:9779->storaged4:9779]" | "SUCCEEDED" | - +--------------------------------------------------------------+-------------------+ | "[1614237867, 11:2, storaged1:9779->storaged3:9779]" | "SUCCEEDED" | - +--------------------------------------------------------------+-------------------+ ... - +--------------------------------------------------------------+-------------------+ | "Total:22, Succeeded:22, Failed:0, In Progress:0, Invalid:0" | 100 | +--------------------------------------------------------------+-------------------+ ``` @@ -77,15 +68,10 @@ | Host | Port | Status | Leader count | Leader distribution | Partition distribution | +-------------+------+----------+--------------+-----------------------------------+------------------------+ | "storaged0" | 9779 | "ONLINE" | 4 | "basketballplayer:4" | "basketballplayer:9" | - +-------------+------+----------+--------------+-----------------------------------+------------------------+ | "storaged1" | 9779 | "ONLINE" | 8 | "basketballplayer:8" | "basketballplayer:9" | - +-------------+------+----------+--------------+-----------------------------------+------------------------+ | "storaged2" | 9779 | "ONLINE" | 3 | "basketballplayer:3" | "basketballplayer:9" | - +-------------+------+----------+--------------+-----------------------------------+------------------------+ | "storaged3" | 9779 | "ONLINE" | 0 | "No valid partition" | "basketballplayer:9" | - +-------------+------+----------+--------------+-----------------------------------+------------------------+ | "storaged4" | 9779 | "ONLINE" | 0 | "No valid partition" | "basketballplayer:9" | - +-------------+------+----------+--------------+-----------------------------------+------------------------+ | "Total" | | | 15 | "basketballplayer:15" | "basketballplayer:45" | +-------------+------+----------+--------------+-----------------------------------+------------------------+ ``` @@ -155,15 +141,10 @@ nebula> SHOW HOSTS; | Host | Port | Status | Leader count | Leader distribution | Partition distribution | +-------------+------+----------+--------------+-----------------------------------+------------------------+ | "storaged0" | 9779 | "ONLINE" | 3 | "basketballplayer:3" | "basketballplayer:9" | -+-------------+------+----------+--------------+-----------------------------------+------------------------+ | "storaged1" | 9779 | "ONLINE" | 3 | "basketballplayer:3" | "basketballplayer:9" | -+-------------+------+----------+--------------+-----------------------------------+------------------------+ | "storaged2" | 9779 | "ONLINE" | 3 | "basketballplayer:3" | "basketballplayer:9" | -+-------------+------+----------+--------------+-----------------------------------+------------------------+ | "storaged3" | 9779 | "ONLINE" | 3 | "basketballplayer:3" | "basketballplayer:9" | -+-------------+------+----------+--------------+-----------------------------------+------------------------+ | "storaged4" | 9779 | "ONLINE" | 3 | "basketballplayer:3" | "basketballplayer:9" | -+-------------+------+----------+--------------+-----------------------------------+------------------------+ | "Total" | | | 15 | "basketballplayer:15" | "basketballplayer:45" | +-------------+------+----------+--------------+-----------------------------------+------------------------+ ``` diff --git a/docs-2.0/nebula-algorithm.md b/docs-2.0/nebula-algorithm.md index ac2f258d2b1..52b936d3fdb 100644 --- a/docs-2.0/nebula-algorithm.md +++ b/docs-2.0/nebula-algorithm.md @@ -1,6 +1,6 @@ # Nebula Algorithm -[Nebula Algorithm](https://github.com/vesoft-inc/nebula-spark-utils/tree/master/nebula-algorithm) (简称Algorithm)是一款基于[GraphX](https://spark.apache.org/graphx/)的Spark应用程序,通过提交Spark任务的形式使用完整的算法工具对Nebula Graph数据库中的数据执行图计算,也可以通过编程形式调用lib库下的算法针对DataFrame执行图计算。 +[Nebula Algorithm](https://github.com/vesoft-inc/nebula-algorithm) (简称Algorithm)是一款基于[GraphX](https://spark.apache.org/graphx/)的Spark应用程序,通过提交Spark任务的形式使用完整的算法工具对Nebula Graph数据库中的数据执行图计算,也可以通过编程形式调用lib库下的算法针对DataFrame执行图计算。 ## 前提条件 @@ -8,7 +8,9 @@ - Nebula Graph 服务已经部署并启动。详细信息,参考[Nebula Graph安装部署](4.deployment-and-installation/1.resource-preparations.md "点击前往 Nebula Graph 安装部署")。 -- Spark 版本为 2.4.x 。 +- Spark 版本为 2.4.x。 + +- Scala 版本为 2.11。 - (可选)如果用户需要在Github中克隆最新的Algorithm,并自行编译打包,可以选择安装[Maven](https://maven.apache.org/download.cgi)。 @@ -32,6 +34,7 @@ Nebula Algorithm支持的图计算算法如下。 |StronglyConnectedComponent| 强联通分量 |社区发现| | ShortestPath | 最短路径 |路径规划、网络规划| | TriangleCount | 三角形计数 |网络结构分析| + | GraphTriangleCount | 全图三角形计数 |网络结构及紧密程度分析| | BetweennessCentrality | 介数中心性 |关键节点挖掘,节点影响力计算| | DegreeStatic | 度统计 |图结构分析| @@ -45,22 +48,22 @@ Nebula Algorithm实现图计算的流程如下: 3. 调用GraphX提供的图算法(例如PageRank)或者自行实现的算法(例如Louvain社区发现)。 -详细的实现方法可以参见相关[Scala文件](https://github.com/vesoft-inc/nebula-spark-utils/tree/master/nebula-algorithm/src/main/scala/com/vesoft/nebula/algorithm/lib)。 +详细的实现方法可以参见相关[Scala文件](https://github.com/vesoft-inc/nebula-algorithm/tree/master/nebula-algorithm/src/main/scala/com/vesoft/nebula/algorithm/lib)。 ## 获取Nebula Algorithm ### 编译打包 -1. 克隆仓库`nebula-spark-utils`。 +1. 克隆仓库`nebula-algorithm`。 ```bash - $ git clone -b {{algorithm.branch}} https://github.com/vesoft-inc/nebula-spark-utils.git + $ git clone -b {{algorithm.branch}} https://github.com/vesoft-inc/nebula-algorithm.git ``` 2. 进入目录`nebula-algorithm`。 ```bash - $ cd nebula-spark-utils/nebula-algorithm + $ cd nebula-algorithm ``` 3. 编译打包。 @@ -85,15 +88,16 @@ Nebula Algorithm实现图计算的流程如下: ```bash - com.vesoft - nebula-algorithm - {{algorithm.release}} + com.vesoft + nebula-algorithm + {{algorithm.release}} ``` -2. 传入参数调用算法(以PageRank为例)。更多算法请参见[测试用例](https://github.com/vesoft-inc/nebula-spark-utils/tree/master/nebula-algorithm/src/test/scala/com/vesoft/nebula/algorithm/lib)。 +2. 传入参数调用算法(以PageRank为例)。更多算法请参见[测试用例](https://github.com/vesoft-inc/nebula-algorithm/tree/master/nebula-algorithm/src/test/scala/com/vesoft/nebula/algorithm/lib)。 !!! note + 执行算法的DataFrame默认第一列是起始点,第二列是目的点,第三列是边权重(非Nebula Graph中的Rank)。 ```bash @@ -106,7 +110,7 @@ Nebula Algorithm实现图计算的流程如下: !!! note 使用封装好的算法包有一定的局限性,例如落库到Nebula Graph时,落库的图空间中创建的Tag的属性名称必须和代码内预设的名称保持一致。如果用户有开发能力,推荐使用第一种方法。 -1. 设置[配置文件](https://github.com/vesoft-inc/nebula-spark-utils/blob/{{algorithm.branch}}/nebula-algorithm/src/main/resources/application.conf)。 +1. 设置[配置文件](https://github.com/vesoft-inc/nebula-algorithm/blob/{{algorithm.branch}}/nebula-algorithm/src/main/resources/application.conf)。 ```bash { @@ -263,7 +267,7 @@ Nebula Algorithm实现图计算的流程如下: 示例: ```bash - ${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.algorithm.Main /root/nebula-spark-utils/nebula-algorithm/target/nebula-algorithm-{{algorithm.release}}.jar -p /root/nebula-spark-utils/nebula-algorithm/src/main/resources/application.conf + ${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.algorithm.Main /root/nebula-algorithm/target/nebula-algorithm-{{algorithm.release}}.jar -p /root/nebula-algorithm/src/main/resources/application.conf ``` ## 视频 diff --git a/docs-2.0/nebula-dashboard/2.deploy-dashboard.md b/docs-2.0/nebula-dashboard/2.deploy-dashboard.md index 64fdb684931..1bce6bf2de5 100644 --- a/docs-2.0/nebula-dashboard/2.deploy-dashboard.md +++ b/docs-2.0/nebula-dashboard/2.deploy-dashboard.md @@ -1,6 +1,6 @@ # 部署Dashboard -安装部署Dashboard涉及5种服务,本文将详细介绍如何安装部署。 +安装部署Dashboard涉及5种服务,本文将详细介绍如何通过 tar 包安装部署。下载和编译Nebula Dashboard的最新源码,请参见[GitHub nebula dashboard](https://github.com/vesoft-inc/nebula-dashboard#readme)页面的说明。 ## Nebula Graph版本 @@ -10,19 +10,25 @@ Dashboard版本和Nebula Graph的版本对应关系如下。 |:---|:---| |{{ dashboard.release }}|2.x| -## 端口说明 +## 前提条件 -部署Dashboard需要占用如下端口: +在部署 Dashboard 之前,用户需要确认以下信息: -- 9200 +- Nebula Graph 服务已经部署并启动。详细信息参考[Nebula Graph安装部署](../4.deployment-and-installation/1.resource-preparations.md "点击前往 Nebula Graph 安装部署")。 -- 9100 +- 确保以下端口未被使用: -- 9090 + - 9200 -- 8090 + - 9100 -- 7003 + - 9090 + + - 8090 + + - 7003 + +- 使用的 Linux 发行版为 CentOS ,安装有版本为 v10.12.0 以上的 Node.js,安装有版本为1.13及以上的Go。 ## 下载Dashboard diff --git a/docs-2.0/nebula-exchange/about-exchange/ex-ug-limitations.md b/docs-2.0/nebula-exchange/about-exchange/ex-ug-limitations.md index 797ebfb11fd..b7b5363a1f5 100644 --- a/docs-2.0/nebula-exchange/about-exchange/ex-ug-limitations.md +++ b/docs-2.0/nebula-exchange/about-exchange/ex-ug-limitations.md @@ -8,8 +8,10 @@ Nebula Exchange版本(即JAR包版本)和Nebula Graph的版本对应关系 |Exchange client版本|Nebula Graph版本| |:---|:---| -|2.5-SNAPSHOT|v2-nightly| +|2.5-SNAPSHOT|nightly| |{{exchange.release}}|{{nebula.release}}| +|2.5.1|2.5.0、2.5.1| +|2.5.0|2.5.0、2.5.1| |2.1.0|2.0.0、2.0.1| |2.0.1|2.0.0、2.0.1| |2.0.0|2.0.0、2.0.1| diff --git a/docs-2.0/nebula-exchange/about-exchange/ex-ug-what-is-exchange.md b/docs-2.0/nebula-exchange/about-exchange/ex-ug-what-is-exchange.md index 4f30f8883f4..b4df90d667b 100644 --- a/docs-2.0/nebula-exchange/about-exchange/ex-ug-what-is-exchange.md +++ b/docs-2.0/nebula-exchange/about-exchange/ex-ug-what-is-exchange.md @@ -1,6 +1,6 @@ # 什么是Nebula Exchange -[Nebula Exchange](https://github.com/vesoft-inc/nebula-spark-utils/tree/{{exchange.branch}}/nebula-exchange)(简称Exchange)是一款Apache Spark™应用,用于在分布式环境中将集群中的数据批量迁移到Nebula Graph中,能支持多种不同格式的批式数据和流式数据的迁移。 +[Nebula Exchange](https://github.com/vesoft-inc/nebula-exchange)(简称Exchange)是一款Apache Spark™应用,用于在分布式环境中将集群中的数据批量迁移到Nebula Graph中,能支持多种不同格式的批式数据和流式数据的迁移。 Exchange由Reader、Processor和Writer三部分组成。Reader读取不同来源的数据返回DataFrame后,Processor遍历DataFrame的每一行,根据配置文件中`fields`的映射关系,按列名获取对应的值。在遍历指定批处理的行数后,Writer会将获取的数据一次性写入到Nebula Graph中。下图描述了Exchange完成数据转换和迁移的过程。 diff --git a/docs-2.0/nebula-exchange/ex-ug-FAQ.md b/docs-2.0/nebula-exchange/ex-ug-FAQ.md index 18467f00eb4..ae2a7437cf0 100644 --- a/docs-2.0/nebula-exchange/ex-ug-FAQ.md +++ b/docs-2.0/nebula-exchange/ex-ug-FAQ.md @@ -78,6 +78,10 @@ nebula-exchange-2.0.0.jar \ - Storage服务可用的端口号有33183、33177、33185。 +### 运行时报错`Exception in thread "main" com.facebook.thrift.protocol.TProtocolException: The field 'code' has been assigned the invalid value -4` + +检查 Exchange 版本与 Nebula Graph 版本是否匹配,详细信息可参考[使用限制](../nebula-exchange/about-exchange/ex-ug-limitations.md)。 + ## 配置问题 ### 哪些配置项影响导入性能? diff --git a/docs-2.0/nebula-exchange/ex-ug-compile.md b/docs-2.0/nebula-exchange/ex-ug-compile.md index 7ac49310da9..2abfc782d0f 100644 --- a/docs-2.0/nebula-exchange/ex-ug-compile.md +++ b/docs-2.0/nebula-exchange/ex-ug-compile.md @@ -11,16 +11,16 @@ ## 编译Exchange -1. 在根目录克隆仓库`nebula-spark-utils`。 +1. 在根目录克隆仓库`nebula-exchange`。 ```bash - git clone -b {{exchange.branch}} https://github.com/vesoft-inc/nebula-spark-utils.git + git clone -b {{exchange.branch}} https://github.com/vesoft-inc/nebula-exchange.git ``` 2. 切换到目录`nebula-exchange`。 ```bash - cd nebula-spark-utils/nebula-exchange + cd nebula-exchange/nebula-exchange ``` 3. 打包Nebula Exchange。 @@ -55,7 +55,7 @@ !!! note JAR文件版本号会因Nebula Java Client的发布版本而变化。用户可以在[Releases页面](https://github.com/vesoft-inc/nebula-java/releases)查看最新版本。 -迁移数据时,用户可以参考配置文件[`target/classes/application.conf`](https://github.com/vesoft-inc/nebula-spark-utils/blob/master/nebula-exchange/src/main/resources/application.conf)。 +迁移数据时,用户可以参考配置文件[`target/classes/application.conf`](https://github.com/vesoft-inc/nebula-exchange/blob/master/nebula-exchange/src/main/resources/application.conf)。 ## 下载依赖包失败 diff --git a/docs-2.0/nebula-exchange/parameter-reference/ex-ug-parameter.md b/docs-2.0/nebula-exchange/parameter-reference/ex-ug-parameter.md index b25020c4591..7a3e81099b9 100644 --- a/docs-2.0/nebula-exchange/parameter-reference/ex-ug-parameter.md +++ b/docs-2.0/nebula-exchange/parameter-reference/ex-ug-parameter.md @@ -1,6 +1,6 @@ # 配置说明 -本文介绍使用Nebula Exchange时如何修改配置文件[`application.conf`](https://github.com/vesoft-inc/nebula-spark-utils/blob/master/nebula-exchange/src/main/resources/application.conf)。 +本文介绍使用Nebula Exchange时如何修改配置文件[`application.conf`](https://github.com/vesoft-inc/nebula-exchange/blob/master/nebula-exchange/src/main/resources/application.conf)。 修改配置文件之前,建议根据数据源复制并修改文件名称,便于区分。例如数据源为CSV文件,可以复制为`csv_application.conf`。 diff --git a/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-clickhouse.md b/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-clickhouse.md index be5c50b8966..32313e76965 100644 --- a/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-clickhouse.md +++ b/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-clickhouse.md @@ -288,7 +288,7 @@ ${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchan 示例: ```bash -${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchange.Exchange /root/nebula-spark-utils/nebula-exchange/target/nebula-exchange-{{exchange.release}}.jar -c /root/nebula-spark-utils/nebula-exchange/target/classes/clickhouse_application.conf +${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchange.Exchange /root/nebula-exchange/nebula-exchange/target/nebula-exchange-{{exchange.release}}.jar -c /root/nebula-exchange/nebula-exchange/target/classes/clickhouse_application.conf ``` 用户可以在返回信息中搜索`batchSuccess.`,确认成功的数量。例如`batchSuccess.follow: 300`。 diff --git a/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-csv.md b/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-csv.md index 738f4c2673c..88ffd0f128b 100644 --- a/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-csv.md +++ b/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-csv.md @@ -379,7 +379,7 @@ ${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchan 示例: ```bash -${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchange.Exchange /root/nebula-spark-utils/nebula-exchange/target/nebula-exchange-{{exchange.release}}.jar -c /root/nebula-spark-utils/nebula-exchange/target/classes/csv_application.conf +${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchange.Exchange /root/nebula-exchange/nebula-exchange/target/nebula-exchange-{{exchange.release}}.jar -c /root/nebula-exchange/nebula-exchange/target/classes/csv_application.conf ``` 用户可以在返回信息中搜索`batchSuccess.`,确认成功的数量。例如`batchSuccess.follow: 300`。 diff --git a/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-hbase.md b/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-hbase.md index 1cfbc660e4b..13b5520c01d 100644 --- a/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-hbase.md +++ b/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-hbase.md @@ -319,7 +319,7 @@ ${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchan 示例: ```bash -${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchange.Exchange /root/nebula-spark-utils/nebula-exchange/target/nebula-exchange-{{exchange.release}}.jar -c /root/nebula-spark-utils/nebula-exchange/target/classes/hbase_application.conf +${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchange.Exchange /root/nebula-exchange/nebula-exchange/target/nebula-exchange-{{exchange.release}}.jar -c /root/nebula-exchange/nebula-exchange/target/classes/hbase_application.conf ``` 用户可以在返回信息中搜索`batchSuccess.`,确认成功的数量。例如`batchSuccess.follow: 300`。 diff --git a/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-hive.md b/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-hive.md index 7b5f60f669b..68c87dc148a 100644 --- a/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-hive.md +++ b/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-hive.md @@ -341,7 +341,7 @@ ${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchan 示例: ```bash -${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchange.Exchange /root/nebula-spark-utils/nebula-exchange/target/nebula-exchange-{{exchange.release}}.jar -c /root/nebula-spark-utils/nebula-exchange/target/classes/hive_application.conf -h +${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchange.Exchange /root/nebula-exchange/nebula-exchange/target/nebula-exchange-{{exchange.release}}.jar -c /root/nebula-exchange/nebula-exchange/target/classes/hive_application.conf -h ``` 用户可以在返回信息中搜索`batchSuccess.`,确认成功的数量。例如`batchSuccess.follow: 300`。 diff --git a/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-json.md b/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-json.md index 39edd0f9633..d35ca59c732 100644 --- a/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-json.md +++ b/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-json.md @@ -197,7 +197,7 @@ # 指定JSON文件的路径。 # 如果文件存储在HDFS上,用双引号括起路径,以hdfs://开头,例如"hdfs://ip:port/xx/xx"。 - # 如果文件存储在本地,用双引号括起路径,以file://开头,例如"file:///tmp/xx.csv"。 + # 如果文件存储在本地,用双引号括起路径,以file://开头,例如"file:///tmp/xx.json"。 path: "hdfs://192.168.*.*:9000/data/vertex_player.json" # 在fields里指定JSON文件中key名称,其对应的value会作为Nebula Graph中指定属性的数据源。 @@ -236,7 +236,7 @@ # 指定JSON文件的路径。 # 如果文件存储在HDFS上,用双引号括起路径,以hdfs://开头,例如"hdfs://ip:port/xx/xx"。 - # 如果文件存储在本地,用双引号括起路径,以file://开头,例如"file:///tmp/xx.csv"。 + # 如果文件存储在本地,用双引号括起路径,以file://开头,例如"file:///tmp/xx.json"。 path: "hdfs://192.168.*.*:9000/data/vertex_team.json" # 在fields里指定JSON文件中key名称,其对应的value会作为Nebula Graph中指定属性的数据源。 @@ -281,7 +281,7 @@ # 指定JSON文件的路径。 # 如果文件存储在HDFS上,用双引号括起路径,以hdfs://开头,例如"hdfs://ip:port/xx/xx"。 - # 如果文件存储在本地,用双引号括起路径,以file://开头,例如"file:///tmp/xx.csv"。 + # 如果文件存储在本地,用双引号括起路径,以file://开头,例如"file:///tmp/xx.json"。 path: "hdfs://192.168.*.*:9000/data/edge_follow.json" # 在fields里指定JSON文件中key名称,其对应的value会作为Nebula Graph中指定属性的数据源。 @@ -327,7 +327,7 @@ # 指定JSON文件的路径。 # 如果文件存储在HDFS上,用双引号括起路径,以hdfs://开头,例如"hdfs://ip:port/xx/xx"。 - # 如果文件存储在本地,用双引号括起路径,以file://开头,例如"file:///tmp/xx.csv"。 + # 如果文件存储在本地,用双引号括起路径,以file://开头,例如"file:///tmp/xx.json"。 path: "hdfs://192.168.*.*:9000/data/edge_serve.json" # 在fields里指定JSON文件中key名称,其对应的value会作为Nebula Graph中指定属性的数据源。 @@ -380,7 +380,7 @@ ${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchan 示例: ```bash -${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchange.Exchange /root/nebula-spark-utils/nebula-exchange/target/nebula-exchange-{{exchange.release}}.jar -c /root/nebula-spark-utils/nebula-exchange/target/classes/json_application.conf +${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchange.Exchange /root/nebula-echange/nebula-exchange/target/nebula-exchange-{{exchange.release}}.jar -c /root/nebula-exchange/nebula-exchange/target/classes/json_application.conf ``` 用户可以在返回信息中搜索`batchSuccess.`,确认成功的数量。例如`batchSuccess.follow: 300`。 diff --git a/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-kafka.md b/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-kafka.md index 4870c497756..a8df7d82a36 100644 --- a/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-kafka.md +++ b/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-kafka.md @@ -280,7 +280,7 @@ ${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchan 示例: ```bash -${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchange.Exchange /root/nebula-spark-utils/nebula-exchange/target/nebula-exchange-{{exchange.release}}.jar -c /root/nebula-spark-utils/nebula-exchange/target/classes/kafka_application.conf +${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchange.Exchange /root/nebula-exchange/nebula-exchange/target/nebula-exchange-{{exchange.release}}.jar -c /root/nebula-exchange/nebula-exchange/target/classes/kafka_application.conf ``` 用户可以在返回信息中搜索`batchSuccess.`,确认成功的数量。例如`batchSuccess.follow: 300`。 diff --git a/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-maxcompute.md b/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-maxcompute.md index 8de5c78fd95..56efb083903 100644 --- a/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-maxcompute.md +++ b/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-maxcompute.md @@ -313,7 +313,7 @@ ${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchan 示例: ```bash -${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchange.Exchange /root/nebula-spark-utils/nebula-exchange/target/nebula-exchange-{{exchange.release}}.jar -c /root/nebula-spark-utils/nebula-exchange/target/classes/maxcompute_application.conf +${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchange.Exchange /root/nebula-exchange/nebula-exchange/target/nebula-exchange-{{exchange.release}}.jar -c /root/nebula-exchange/nebula-exchange/target/classes/maxcompute_application.conf ``` 用户可以在返回信息中搜索`batchSuccess.`,确认成功的数量。例如`batchSuccess.follow: 300`。 diff --git a/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-mysql.md b/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-mysql.md index 057552898b6..1bb6083db9a 100644 --- a/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-mysql.md +++ b/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-mysql.md @@ -329,7 +329,7 @@ ${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchan 示例: ```bash -${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchange.Exchange /root/nebula-spark-utils/nebula-exchange/target/nebula-exchange-{{exchange.release}}.jar -c /root/nebula-spark-utils/nebula-exchange/target/classes/mysql_application.conf +${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchange.Exchange /root/nebula-exchange/nebula-exchange/target/nebula-exchange-{{exchange.release}}.jar -c /root/nebula-exchange/nebula-exchange/target/classes/mysql_application.conf ``` 用户可以在返回信息中搜索`batchSuccess.`,确认成功的数量。例如`batchSuccess.follow: 300`。 diff --git a/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-neo4j.md b/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-neo4j.md index 91090509c1a..b27680b8a0b 100644 --- a/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-neo4j.md +++ b/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-neo4j.md @@ -232,6 +232,7 @@ Exchange读取Neo4j数据时需要完成以下工作: target: { field: dst } + #ranking: rank partition: 10 batch: 1000 check_point_path: /tmp/test @@ -256,6 +257,7 @@ Exchange读取Neo4j数据时需要完成以下工作: target: { field: dst } + #ranking: rank partition: 10 batch: 1000 check_point_path: /tmp/test @@ -295,7 +297,7 @@ ${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchan 示例: ```bash -${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchange.Exchange /root/nebula-spark-utils/nebula-exchange/target/nebula-exchange-{{exchange.release}}.jar -c /root/nebula-spark-utils/nebula-exchange/target/classes/neo4j_application.conf +${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchange.Exchange /root/nebula-exchange/nebula-exchange/target/nebula-exchange-{{exchange.release}}.jar -c /root/nebula-exchange/nebula-exchange/target/classes/neo4j_application.conf ``` 用户可以在返回信息中搜索`batchSuccess.`,确认成功的数量。例如`batchSuccess.follow: 300`。 diff --git a/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-orc.md b/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-orc.md index 17294cb0748..e4e41a53624 100644 --- a/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-orc.md +++ b/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-orc.md @@ -165,7 +165,7 @@ # 指定ORC文件的路径。 # 如果文件存储在HDFS上,用双引号括起路径,以hdfs://开头,例如"hdfs://ip:port/xx/xx"。 - # 如果文件存储在本地,用双引号括起路径,以file://开头,例如"file:///tmp/xx.csv"。 + # 如果文件存储在本地,用双引号括起路径,以file://开头,例如"file:///tmp/xx.orc"。 path: "hdfs://192.168.*.*:9000/data/vertex_player.orc" # 在fields里指定ORC文件中key名称,其对应的value会作为Nebula Graph中指定属性的数据源。 @@ -204,7 +204,7 @@ # 指定ORC文件的路径。 # 如果文件存储在HDFS上,用双引号括起路径,以hdfs://开头,例如"hdfs://ip:port/xx/xx"。 - # 如果文件存储在本地,用双引号括起路径,以file://开头,例如"file:///tmp/xx.csv"。 + # 如果文件存储在本地,用双引号括起路径,以file://开头,例如"file:///tmp/xx.orc"。 path: "hdfs://192.168.*.*:9000/data/vertex_team.orc" # 在fields里指定ORC文件中key名称,其对应的value会作为Nebula Graph中指定属性的数据源。 @@ -249,7 +249,7 @@ # 指定ORC文件的路径。 # 如果文件存储在HDFS上,用双引号括起路径,以hdfs://开头,例如"hdfs://ip:port/xx/xx"。 - # 如果文件存储在本地,用双引号括起路径,以file://开头,例如"file:///tmp/xx.csv"。 + # 如果文件存储在本地,用双引号括起路径,以file://开头,例如"file:///tmp/xx.orc"。 path: "hdfs://192.168.*.*:9000/data/edge_follow.orc" # 在fields里指定ORC文件中key名称,其对应的value会作为Nebula Graph中指定属性的数据源。 @@ -295,7 +295,7 @@ # 指定ORC文件的路径。 # 如果文件存储在HDFS上,用双引号括起路径,以hdfs://开头,例如"hdfs://ip:port/xx/xx"。 - # 如果文件存储在本地,用双引号括起路径,以file://开头,例如"file:///tmp/xx.csv"。 + # 如果文件存储在本地,用双引号括起路径,以file://开头,例如"file:///tmp/xx.orc"。 path: "hdfs://192.168.*.*:9000/data/edge_serve.orc" # 在fields里指定ORC文件中key名称,其对应的value会作为Nebula Graph中指定属性的数据源。 @@ -348,7 +348,7 @@ ${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchan 示例: ```bash -${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchange.Exchange /root/nebula-spark-utils/nebula-exchange/target/nebula-exchange-{{exchange.release}}.jar -c /root/nebula-spark-utils/nebula-exchange/target/classes/orc_application.conf +${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchange.Exchange /root/nebula-exchange/nebula-exchange/target/nebula-exchange-{{exchange.release}}.jar -c /root/nebula-exchange/nebula-exchange/target/classes/orc_application.conf ``` 用户可以在返回信息中搜索`batchSuccess.`,确认成功的数量。例如`batchSuccess.follow: 300`。 diff --git a/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-parquet.md b/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-parquet.md index 1f59e7d2d37..e412a7f6f11 100644 --- a/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-parquet.md +++ b/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-parquet.md @@ -348,7 +348,7 @@ ${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchan 示例: ```bash -${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchange.Exchange /root/nebula-spark-utils/nebula-exchange/target/nebula-exchange-{{exchange.release}}.jar -c /root/nebula-spark-utils/nebula-exchange/target/classes/parquet_application.conf +${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchange.Exchange /root/nebula-exchange/nebula-exchange/target/nebula-exchange-{{exchange.release}}.jar -c /root/nebula-exchange/nebula-exchange/target/classes/parquet_application.conf ``` 用户可以在返回信息中搜索`batchSuccess.`,确认成功的数量。例如`batchSuccess.follow: 300`。 diff --git a/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-pulsar.md b/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-pulsar.md index e839a4222c1..c9697a6d6cf 100644 --- a/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-pulsar.md +++ b/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-pulsar.md @@ -289,7 +289,7 @@ ${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchan 示例: ```bash -${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchange.Exchange /root/nebula-spark-utils/nebula-exchange/target/nebula-exchange-{{exchange.release}}.jar -c /root/nebula-spark-utils/nebula-exchange/target/classes/pulsar_application.conf +${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchange.Exchange /root/nebula-exchange/nebula-exchange/target/nebula-exchange-{{exchange.release}}.jar -c /root/nebula-exchange/nebula-exchange/target/classes/pulsar_application.conf ``` 用户可以在返回信息中搜索`batchSuccess.`,确认成功的数量。例如`batchSuccess.follow: 300`。 diff --git a/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-sst.md b/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-sst.md index f62aa165d68..1edc347de39 100644 --- a/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-sst.md +++ b/docs-2.0/nebula-exchange/use-exchange/ex-ug-import-from-sst.md @@ -2,7 +2,11 @@ 本文以一个示例说明如何将数据源的数据生成SST(Sorted String Table)文件并保存在HDFS上,然后导入Nebula Graph,示例数据源是CSV文件。 -> **说明**:仅Linux系统支持导入SST文件。 +## 注意事项 + +- 仅Linux系统支持导入SST文件。 + +- 不支持属性的Default值。 ## 背景信息 @@ -242,7 +246,7 @@ SST文件是一个内部包含了任意长度的有序键值对集合的文件 } # 指定CSV文件的路径。 - # 文件存储在HDFS上,用双引号括起路径,以hdfs://开头,例如"hdfs://ip:port/xx/xx"。 + # 文件存储在HDFS上,用双引号括起路径,以hdfs://开头,例如"hdfs://ip:port/xx/xx.csv"。 path: "hdfs://*.*.*.*:9000/dataset/vertex_player.csv" # 如果CSV文件没有表头,使用[_c0, _c1, _c2, ..., _cn]表示其表头,并将列指示为属性值的源。 @@ -287,7 +291,7 @@ SST文件是一个内部包含了任意长度的有序键值对集合的文件 } # 指定CSV文件的路径。 - # 文件存储在HDFS上,用双引号括起路径,以hdfs://开头,例如"hdfs://ip:port/xx/xx"。 + # 文件存储在HDFS上,用双引号括起路径,以hdfs://开头,例如"hdfs://ip:port/xx/xx.csv"。 path: "hdfs://*.*.*.*:9000/dataset/vertex_team.csv" # 如果CSV文件没有表头,使用[_c0, _c1, _c2, ..., _cn]表示其表头,并将列指示为属性值的源。 @@ -337,7 +341,7 @@ SST文件是一个内部包含了任意长度的有序键值对集合的文件 } # 指定CSV文件的路径。 - # 文件存储在HDFS上,用双引号括起路径,以hdfs://开头,例如"hdfs://ip:port/xx/xx"。 + # 文件存储在HDFS上,用双引号括起路径,以hdfs://开头,例如"hdfs://ip:port/xx/xx.csv"。 path: "hdfs://*.*.*.*:9000/dataset/edge_follow.csv" # 如果CSV文件没有表头,使用[_c0, _c1, _c2, ..., _cn]表示其表头,并将列指示为属性值的源。 @@ -389,7 +393,7 @@ SST文件是一个内部包含了任意长度的有序键值对集合的文件 } # 指定CSV文件的路径。 - # 文件存储在HDFS上,用双引号括起路径,以hdfs://开头,例如"hdfs://ip:port/xx/xx"。 + # 文件存储在HDFS上,用双引号括起路径,以hdfs://开头,例如"hdfs://ip:port/xx/xx.csv"。 path: "hdfs://*.*.*.*:9000/dataset/edge_serve.csv" # 如果CSV文件没有表头,使用[_c0, _c1, _c2, ..., _cn]表示其表头,并将列指示为属性值的源。 @@ -437,7 +441,7 @@ SST文件是一个内部包含了任意长度的有序键值对集合的文件 运行如下命令将CSV源文件生成为SST文件。关于参数的说明,请参见[命令参数](../parameter-reference/ex-ug-para-import-command.md)。 ```bash -${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchange.Exchange -c +${SPARK_HOME}/bin/spark-submit --master "local" --conf spark.sql.shuffle.partition= --class com.vesoft.nebula.exchange.Exchange -c ``` !!! note @@ -447,7 +451,7 @@ ${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchan 示例: ```bash -${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.exchange.Exchange /root/nebula-spark-utils/nebula-exchange/target/nebula-exchange-{{exchange.release}}.jar -c /root/nebula-spark-utils/nebula-exchange/target/classes/sst_application.conf +${SPARK_HOME}/bin/spark-submit --master "local" --conf spark.sql.shuffle.partition=200 --class com.vesoft.nebula.exchange.Exchange /root/nebula-exchange/nebula-exchange/target/nebula-exchange-{{exchange.release}}.jar -c /root/nebula-exchange/nebula-exchange/target/classes/sst_application.conf ``` 任务执行完成后,可以在HDFS上的`/sst`目录(`nebula.path.remote`参数指定)内查看到生成的SST文件。 @@ -496,7 +500,7 @@ ${SPARK_HOME}/bin/spark-submit --master "local" --class com.vesoft.nebula.excha !!! note - - 如果需要重新下载,请在Nebula Graph安装路径内的`data/storage/nebula`目录内,将对应Space ID目录内的`download`文件夹删除,然后重新下载SST文件。如果是图空间是多副本,保存副本的所有机器都需要删除`download`文件夹。 + - 如果需要重新下载,请在Nebula Graph安装路径内的`data/storage/nebula`目录内,将对应Space ID目录内的`download`文件夹删除,然后重新下载SST文件。如果图空间是多副本,保存副本的所有机器都需要删除`download`文件夹。 - 如果导入时出现问题需要重新导入,重新执行`INGEST;`即可。 diff --git a/docs-2.0/nebula-explorer/about-explorer/ex-ug-what-is-explorer.md b/docs-2.0/nebula-explorer/about-explorer/ex-ug-what-is-explorer.md index d5cc2d6ba11..9578bdcb10d 100644 --- a/docs-2.0/nebula-explorer/about-explorer/ex-ug-what-is-explorer.md +++ b/docs-2.0/nebula-explorer/about-explorer/ex-ug-what-is-explorer.md @@ -2,6 +2,8 @@ Nebula Explorer (简称 Explorer)是一款可以通过 Web 访问的图探索可视化工具,搭配 Nebula Graph 内核使用,用于与图数据进行可视化交互。即使没有图数据操作经验,用户也可以快速成为图专家。 +![Explorer](../figs/explorer.png) + !!! enterpriseonly Explorer 仅在企业版提供。 diff --git a/docs-2.0/nebula-explorer/deploy-connect/ex-ug-connect.md b/docs-2.0/nebula-explorer/deploy-connect/ex-ug-connect.md index 48e92ef7514..0368ebd5146 100644 --- a/docs-2.0/nebula-explorer/deploy-connect/ex-ug-connect.md +++ b/docs-2.0/nebula-explorer/deploy-connect/ex-ug-connect.md @@ -33,11 +33,11 @@ - 如果已启用身份验证,但是未创建账号信息,用户只能以 GOD 角色登录,必须填写 `root` 及对应的密码 `nebula`。 - 如果已启用身份验证,同时又创建了不同的用户并分配了角色,不同角色的用户使用自己的账号和密码登录。 - ![Nebula Graph Explorer 的登录页面](../figs/ex-ug-002-1.png "配置数据库") + ![Nebula Graph Explorer 的登录页面](../figs/ex-ug-002.png) -2. 完成设置后,点击 **连接** 按钮。 +2. 完成设置后,点击 **登录** 按钮。 如果能看到如下图所示的界面,表示已经成功连接到 Nebula Graph 数据库。 - ![Explorer 进入控制台页面,表示成功连接到 Nebula Graph](../figs/ex-ug-003-1.png "Nebula Graph 连接成功") + ![Explorer 进入控制台页面,表示成功连接到 Nebula Graph](../figs/ex-ug-003.png "Nebula Graph 连接成功") 一次连接会话持续 30 分钟。如果超过 30 分钟没有操作,会话即断开,用户需要重新登录数据库。 diff --git a/docs-2.0/nebula-explorer/deploy-connect/ex-ug-deploy.md b/docs-2.0/nebula-explorer/deploy-connect/ex-ug-deploy.md index 79436a4e5c6..57fee0bbbd5 100644 --- a/docs-2.0/nebula-explorer/deploy-connect/ex-ug-deploy.md +++ b/docs-2.0/nebula-explorer/deploy-connect/ex-ug-deploy.md @@ -21,7 +21,7 @@ !!! caution - 目前 Nebula Explorer 提供的包仅在 Linux 环境中使用,如果用户使用 mac 或其他环境,需要克隆[http-gateway repo](https://github.com/vesoft-inc/nebula-http-gateway),并修改 `nebula-http-gateway/conf/app.conf` 文件中的`httpport = 8070` 使用 `make` 命令编译启动。 + 目前 Nebula Explorer 提供的包仅在 Linux 环境中使用,如果用户使用 mac 或其他环境,需要克隆 [http-gateway repo](https://github.com/vesoft-inc/nebula-http-gateway),并修改 `nebula-http-gateway/conf/app.conf` 文件中的 `httpport = 8070` 后使用 `make` 命令编译启动。 ### 安装 @@ -39,7 +39,6 @@ $ sudo rpm -i nebula-graph-explorer-.x86_64.rpm ``` - ### 卸载 使用以下的命令卸载 Explorer 。 @@ -135,6 +134,6 @@ $ npm run stop # 停止 nebula-graph-explorer 在浏览器窗口中看到以下登录界面表示已经成功部署并启动了 Explorer。 -![Nebula Explorer 登录页面](../figs/ex-ug-001.png) +![Nebula Explorer 登录页面](../figs/ex-ug-002.png) 进入 Explorer 登录界面后,用户需要连接 Nebula Graph。详细信息,参考[连接数据库](../deploy-connect/ex-ug-connect.md)。 diff --git a/docs-2.0/nebula-explorer/deploy-connect/ex-ug-reset-connection.md b/docs-2.0/nebula-explorer/deploy-connect/ex-ug-reset-connection.md index 954030b74b4..fc69cc3afe4 100644 --- a/docs-2.0/nebula-explorer/deploy-connect/ex-ug-reset-connection.md +++ b/docs-2.0/nebula-explorer/deploy-connect/ex-ug-reset-connection.md @@ -1,7 +1,6 @@ -# 清除连接 +# 清空链接 Explorer 还连接在某个 Nebula Graph 数据库时,在工具栏中,选择 设置 ![icon](../figs/nav-setup.png) > 清空连接,如下图所示: -![清除链接](../figs/ex-ug-004-1.png) +![清空链接](../figs/ex-ug-004.png) 之后,如果浏览器上显示 **配置数据库** 页面,表示 Explorer 已经成功断开了与 Nebula Graph 数据库的连接。 - diff --git a/docs-2.0/nebula-explorer/figs/ex-ug-002.png b/docs-2.0/nebula-explorer/figs/ex-ug-002.png index 879f4b286b1..f5db7ef3880 100644 Binary files a/docs-2.0/nebula-explorer/figs/ex-ug-002.png and b/docs-2.0/nebula-explorer/figs/ex-ug-002.png differ diff --git a/docs-2.0/nebula-explorer/figs/ex-ug-003-1.png b/docs-2.0/nebula-explorer/figs/ex-ug-003-1.png deleted file mode 100644 index 559dfb653cb..00000000000 Binary files a/docs-2.0/nebula-explorer/figs/ex-ug-003-1.png and /dev/null differ diff --git a/docs-2.0/nebula-explorer/figs/ex-ug-003.png b/docs-2.0/nebula-explorer/figs/ex-ug-003.png new file mode 100644 index 00000000000..edfddf141bb Binary files /dev/null and b/docs-2.0/nebula-explorer/figs/ex-ug-003.png differ diff --git a/docs-2.0/nebula-explorer/figs/ex-ug-004.png b/docs-2.0/nebula-explorer/figs/ex-ug-004.png index 337215531f9..f957f356bc6 100644 Binary files a/docs-2.0/nebula-explorer/figs/ex-ug-004.png and b/docs-2.0/nebula-explorer/figs/ex-ug-004.png differ diff --git a/docs-2.0/nebula-explorer/figs/ex-ug-009-2.png b/docs-2.0/nebula-explorer/figs/ex-ug-009-2.png new file mode 100644 index 00000000000..c4dd12bcb63 Binary files /dev/null and b/docs-2.0/nebula-explorer/figs/ex-ug-009-2.png differ diff --git a/docs-2.0/nebula-explorer/figs/ex-ug-011-2.png b/docs-2.0/nebula-explorer/figs/ex-ug-011-2.png new file mode 100644 index 00000000000..40d87530d4f Binary files /dev/null and b/docs-2.0/nebula-explorer/figs/ex-ug-011-2.png differ diff --git a/docs-2.0/nebula-explorer/figs/ex-ug-012-2.png b/docs-2.0/nebula-explorer/figs/ex-ug-012-2.png new file mode 100644 index 00000000000..10cb6922100 Binary files /dev/null and b/docs-2.0/nebula-explorer/figs/ex-ug-012-2.png differ diff --git a/docs-2.0/nebula-explorer/figs/ex-ug-013-2.png b/docs-2.0/nebula-explorer/figs/ex-ug-013-2.png new file mode 100644 index 00000000000..807fc22ae23 Binary files /dev/null and b/docs-2.0/nebula-explorer/figs/ex-ug-013-2.png differ diff --git a/docs-2.0/nebula-explorer/figs/ex-ug-014-2.png b/docs-2.0/nebula-explorer/figs/ex-ug-014-2.png new file mode 100644 index 00000000000..353715a6dfa Binary files /dev/null and b/docs-2.0/nebula-explorer/figs/ex-ug-014-2.png differ diff --git a/docs-2.0/nebula-explorer/figs/ex-ug-015-2.png b/docs-2.0/nebula-explorer/figs/ex-ug-015-2.png new file mode 100644 index 00000000000..e4e3d4365b6 Binary files /dev/null and b/docs-2.0/nebula-explorer/figs/ex-ug-015-2.png differ diff --git a/docs-2.0/nebula-explorer/figs/ex-ug-016-2.png b/docs-2.0/nebula-explorer/figs/ex-ug-016-2.png new file mode 100644 index 00000000000..00aa0088298 Binary files /dev/null and b/docs-2.0/nebula-explorer/figs/ex-ug-016-2.png differ diff --git a/docs-2.0/nebula-explorer/figs/ex-ug-017-2.png b/docs-2.0/nebula-explorer/figs/ex-ug-017-2.png new file mode 100644 index 00000000000..89908c55b85 Binary files /dev/null and b/docs-2.0/nebula-explorer/figs/ex-ug-017-2.png differ diff --git a/docs-2.0/nebula-explorer/figs/ex-ug-018-2.png b/docs-2.0/nebula-explorer/figs/ex-ug-018-2.png new file mode 100644 index 00000000000..d14aba6a11b Binary files /dev/null and b/docs-2.0/nebula-explorer/figs/ex-ug-018-2.png differ diff --git a/docs-2.0/nebula-explorer/figs/ex-ug-023.png b/docs-2.0/nebula-explorer/figs/ex-ug-023.png new file mode 100644 index 00000000000..05f4b6bcddd Binary files /dev/null and b/docs-2.0/nebula-explorer/figs/ex-ug-023.png differ diff --git a/docs-2.0/nebula-explorer/figs/ex-ug-025.png b/docs-2.0/nebula-explorer/figs/ex-ug-025.png new file mode 100644 index 00000000000..58daa0d63cf Binary files /dev/null and b/docs-2.0/nebula-explorer/figs/ex-ug-025.png differ diff --git a/docs-2.0/nebula-explorer/figs/ex-ug-028.png b/docs-2.0/nebula-explorer/figs/ex-ug-028.png new file mode 100644 index 00000000000..679f2124b53 Binary files /dev/null and b/docs-2.0/nebula-explorer/figs/ex-ug-028.png differ diff --git a/docs-2.0/nebula-explorer/figs/ex-ug-029.png b/docs-2.0/nebula-explorer/figs/ex-ug-029.png new file mode 100644 index 00000000000..bb52a95a8ff Binary files /dev/null and b/docs-2.0/nebula-explorer/figs/ex-ug-029.png differ diff --git a/docs-2.0/nebula-explorer/figs/explorer.png b/docs-2.0/nebula-explorer/figs/explorer.png new file mode 100644 index 00000000000..d8c44492196 Binary files /dev/null and b/docs-2.0/nebula-explorer/figs/explorer.png differ diff --git a/docs-2.0/nebula-explorer/figs/nav-filter.png b/docs-2.0/nebula-explorer/figs/nav-filter.png new file mode 100644 index 00000000000..b05eea3a517 Binary files /dev/null and b/docs-2.0/nebula-explorer/figs/nav-filter.png differ diff --git a/docs-2.0/nebula-explorer/operation-guide/ex-ug-canvas.md b/docs-2.0/nebula-explorer/operation-guide/ex-ug-canvas.md index 94522babaf6..fb3eb871a1e 100644 --- a/docs-2.0/nebula-explorer/operation-guide/ex-ug-canvas.md +++ b/docs-2.0/nebula-explorer/operation-guide/ex-ug-canvas.md @@ -4,7 +4,7 @@ ## 查看点边 -移动鼠标到点或边上,详细查看点和边的数据。以下展示 VID 为 `107` 的点的详细信息: +移动鼠标到点或边上,详细查看点和边的数据,同一点上的多个 Tag 通过`|`分开。以下展示 VID 为 `107` 的点的详细信息: ![show](../figs/ex-ug-024-1.png) ## 批量选中 @@ -15,13 +15,12 @@ Explorer 支持批量选中多个点边,并查看选中点边的数据,详 ### 框选操作 点击![frameselect](../figs/nav-frameSelect.png) 图标后,按住左键拖拽并框选多个点和边。示例如下: -![slect](../figs/ex-ug-023-1.png) +![select](../figs/ex-ug-023.png) + ### 点击选择多个节边 点击![singleselect](../figs/nav-singleSelect.png) 图标或按住 Shift 后,用鼠标单击并选中多个点和边,单击空白处取消选择。示例如下: -![select](../figs/ex-ug-025-1.png) - - +![select](../figs/ex-ug-025.png) ## 快速操作 @@ -29,3 +28,13 @@ Explorer 支持批量选中多个点边,并查看选中点边的数据,详 ![quick](../figs/ex-ug-026-1.png) 点击 **适合选中尺寸** 可以将选中的数据,移动到画布的中心,方便用户查看。 + +## 节点筛选 + +用户可以对画布中显示的点进行过滤。在该示例中,选择 Tag 为 `player`,`age>=35` 的点,并启动过滤。 + +!!! note + + 每一组筛选条件只针对带此 Tag 的数据,满足条件会被自动添加选中状态,不满足则置灰。其他 Tag 数据状态不受影响。 + +![filter](../figs/ex-ug-029.png) diff --git a/docs-2.0/nebula-explorer/operation-guide/ex-ug-graph-exploration.md b/docs-2.0/nebula-explorer/operation-guide/ex-ug-graph-exploration.md index 657d5e2f186..0d73b3c8102 100644 --- a/docs-2.0/nebula-explorer/operation-guide/ex-ug-graph-exploration.md +++ b/docs-2.0/nebula-explorer/operation-guide/ex-ug-graph-exploration.md @@ -15,22 +15,22 @@ 面板内配置修改后会保存当前配置,当双击或者右键快捷拓展时候会以当前配置进行拓展。 -![expand](../figs/ex-ug-013-1.png) +![expand](../figs/ex-ug-013-2.png) ## 共同邻居 在菜单栏,点击 ![commonneighbor](../figs/rightclickmenu-commonNeighbor.png) 图标,打开 **共同邻居** 窗口。用户可以选中画布中的两个点或多个点,查询它们的共同邻居。选中的点无共同邻居时,默认返回 **没有相应数据** 。 -![common_neighbor](../figs/ex-ug-014-1.png) +![common_neighbor](../figs/ex-ug-014-2.png) ## 路径查询 在菜单栏,点击 ![findpath](../figs/rightclickmenu-findPath.png) 图标,打开 **路径查询** 窗口。用户可以选中画布中的两个点,默认框选的第一个点为起点,第二个点为终点。用户可自定义边的类型和方向,规定拓展步数,选择查询以下三种路径: `All path`,`Shortest path` 和 `Noloop path`。 -![find_path](../figs/ex-ug-015-1.png) +![find_path](../figs/ex-ug-015-2.png) ## 查看属性 在菜单栏,点击 ![propertyview](../figs/nav-propertyView.png) 图标,打开 **查看属性** 窗口。用户可以选择在画布中展示或隐藏点或边的属性。点击确认后,缩放比例大于 100% 时候才会显示属性在画布上,小于 100% 的时候会自动隐藏。 -![show_property](../figs/ex-ug-016-1.png) +![show_property](../figs/ex-ug-016-2.png) diff --git a/docs-2.0/nebula-explorer/operation-guide/ex-ug-page-overview.md b/docs-2.0/nebula-explorer/operation-guide/ex-ug-page-overview.md index 4126872cf28..a2241968fb1 100644 --- a/docs-2.0/nebula-explorer/operation-guide/ex-ug-page-overview.md +++ b/docs-2.0/nebula-explorer/operation-guide/ex-ug-page-overview.md @@ -4,7 +4,7 @@ ## 概览 -![Explorer](../figs/ex-ug-006.png) +![Explorer](../figs/explorer.png) Explorer 的主页面分为五个部分: - 标签栏 @@ -17,6 +17,8 @@ Explorer 的主页面分为五个部分: - 导出图形:支持导出当前视图的 CSV 文件或 PNG(图片)文件。 +- 新增画布:支持创建多个画布,最多仅能打开10个画布。 + ## 侧边栏 侧边栏包括五个部分,用户可以点击按钮对图进行探索、修改画布上点的内容等等。 @@ -40,7 +42,8 @@ Explorer 的主页面分为五个部分: - 框选模式:单击![frameSelect](../figs/nav-frameSelect.png) 图标,支持框选画布中的点和边。 - 选中多条点边:单击![singleSelect](../figs/nav-singleSelect.png) 图标,可以方便的点击画布中的点和边,单击空白处取消选择。 - 拖动画布:单击![moveCanvas](../figs/nav-moveCanvas.png) 图标,支持拖动画布的位置。 -- +- 节点过滤:单击![filter](../figs/nav-filter.png)图标,支持对画布中显示的点进行过滤。 + 更多详细信息参考 [画布操作](../operation-guide/ex-ug-canvas.md)。 ### 图探索扩展 @@ -49,7 +52,7 @@ Explorer 的主页面分为五个部分: - 共同邻居:单击 ![commonNeighbor](../figs/rightclickmenu-commonNeighbor.png)图标,选择页面上至少两个点并查看它们的共同邻居。 - 路径查询:单击 ![findPath](../figs/rightclickmenu-findPath.png)图标,可以查询起点到终点之间的 `all paths` 、 `Shortest path` 或者是 `Noloop path` 的路径。 - 查看属性:单击 ![propertyView](../figs/nav-propertyView.png)图标,选择是否显画布中的点或边的属性值。 -- + 更多详细信息参考 [图探索拓展](../operation-guide/ex-ug-graph-exploration.md)。 ### 删除及撤销 @@ -63,6 +66,7 @@ Explorer 的主页面分为五个部分: - 选择图空间:单击 ![graphSpace](../figs/nav-graphSpace.png)图标,切换当前图空间。 - 帮助:单击 ![help](../figs/nav-help.png)图标,查看更多信息。 - 设置:单击 ![setup](../figs/nav-setup.png)图标,可以查看用户名和快捷键、修改语言设置、清除 Explorer 链接等。 + ## 画布 画布主要分为: diff --git a/docs-2.0/nebula-explorer/operation-guide/ex-ug-query-exploration.md b/docs-2.0/nebula-explorer/operation-guide/ex-ug-query-exploration.md index c95a02d513f..e909b089798 100644 --- a/docs-2.0/nebula-explorer/operation-guide/ex-ug-query-exploration.md +++ b/docs-2.0/nebula-explorer/operation-guide/ex-ug-query-exploration.md @@ -10,14 +10,14 @@ 用户可以通过输入VID或者生成VID的数据查询,一行仅支持一个数据。同时也支持随机导入数据和文件导入数据。确认添加后,数据会显示在画布中。以下给出示例: -![VID](../figs/ex-ug-009-1.png) +![VID](../figs/ex-ug-009-2.png) ## Tag 查询 基于 Tag 查询,必选值为 Tag 和索引。用户可以对输出的结果进行数量上的限制和结果进行过滤。以下查询 10 个年龄大于 30 岁,且不等于 40 岁的球员,示例如下: -![Tag](../figs/ex-ug-011-1.png) +![Tag](../figs/ex-ug-011-2.png) ## 子图查询 基于子图查询,必选值为 VID 。用户可以查看一个或多个点的子图,支持规定子图的步数、边类型及流入流出的方向。以下给出 VID 值为 101 ,步数为 4 ,边类型为 server 和 like 的入边的示例: -![Query](../figs/ex-ug-012-1.png) \ No newline at end of file +![Query](../figs/ex-ug-012-2.png) \ No newline at end of file diff --git a/docs-2.0/nebula-explorer/operation-guide/ex-ug-relationship-list.md b/docs-2.0/nebula-explorer/operation-guide/ex-ug-relationship-list.md index cf4434598ac..bfab6137f17 100644 --- a/docs-2.0/nebula-explorer/operation-guide/ex-ug-relationship-list.md +++ b/docs-2.0/nebula-explorer/operation-guide/ex-ug-relationship-list.md @@ -1,11 +1,11 @@ # 关系列表 -用户可以在关系列表中,选中点和边。选中 Tag 为 `player` 和 `team` 的 5 个点,选中 Edge 为 `serve` 的 6 条边,示例如下: +用户可以在关系列表中,选中点和边。选中 Tag 为 `player` 的 9 个点,选中 Edge 为 `serve` 的 7 条边,示例如下: -![select](../figs/ex-ug-017-1.png) +![select](../figs/ex-ug-017-2.png) 同时,用户可以修改 Tag 的颜色和图标,使得关键节点更为突出。 -在默认情况下,Tag 完全相同的 VID 点的颜色相同,并且也支持手动修改一个点或一组 Tag 完全相同的点的颜色。例如标签为 `bachelor`, `player`和 `team` 的点,修改其中一个点的颜色,在关系列表中你可以点开查看,示例如下: +在默认情况下,Tag 完全相同的 VID 点的颜色相同,并且也支持手动修改一个点或一组 Tag 完全相同的点的颜色及图标。例如标签为 `bachelor`, `player`和 `team` 的点,修改其中一个点的颜色,在关系列表中你可以点开查看,示例如下: -![icon](../figs/ex-ug-018-1.png) \ No newline at end of file +![icon](../figs/ex-ug-018-2.png) \ No newline at end of file diff --git a/docs-2.0/nebula-operator/2.deploy-nebula-operator.md b/docs-2.0/nebula-operator/2.deploy-nebula-operator.md index 045f9dbd825..e554c94e89e 100644 --- a/docs-2.0/nebula-operator/2.deploy-nebula-operator.md +++ b/docs-2.0/nebula-operator/2.deploy-nebula-operator.md @@ -138,7 +138,7 @@ scheduler: | `imagePullSecrets` | - | 镜像拉取密钥。 | | `kubernetesClusterDomain` | `cluster.local`。 | 集群域名。 | | `controllerManager.create` | `true` | 是否启用controller-manager。 | -| `controllerManager.replicas` | `2` | controller-manger副本数。 | +| `controllerManager.replicas` | `2` | controller-manager副本数。 | | `admissionWebhook.create` | `true` | 是否启用Admission Webhook。 | | `shceduler.create` | `true` | 是否启用Scheduler。 | | `shceduler.schedulerName` | `nebula-scheduler` | 调度器名称。 | diff --git a/docs-2.0/nebula-operator/3.deploy-nebula-graph-cluster/3.2create-cluster-with-helm.md b/docs-2.0/nebula-operator/3.deploy-nebula-graph-cluster/3.2create-cluster-with-helm.md index 82e17c262b1..d6996180628 100644 --- a/docs-2.0/nebula-operator/3.deploy-nebula-graph-cluster/3.2create-cluster-with-helm.md +++ b/docs-2.0/nebula-operator/3.deploy-nebula-graph-cluster/3.2create-cluster-with-helm.md @@ -6,7 +6,7 @@ ## 创建Nebula Graph集群 -1. 添加Nebula Operator chart至Helm仓库(如已创添加,略过前面1至2步,从第3步开始执行)。 +1. 添加Nebula Operator chart仓库至Helm(如已创添加,略过前面1至2步,从第3步开始执行)。 ```bash helm repo add nebula-operator https://vesoft-inc.github.io/nebula-operator/charts @@ -121,4 +121,4 @@ helm uninstall "${NEBULA_CLUSTER_NAME}" --namespace="${NEBULA_CLUSTER_NAMESPACE} | `nebula.storaged.env` | `[]` | Storaged服务的环境变量。 | | `nebula.storaged.resources` | `{"resources":{"requests":{"cpu":"500m","memory":"500Mi"},"limits":{"cpu":"1","memory":"1Gi"}}}` | Storaged服务的资源配置。 | | `nebula.storaged.storage` | `1Gi` | Storaged服务的存储空间值。 | -| `imagePullSecrets` | `[]` | 拉取镜像的Secret。 | \ No newline at end of file +| `imagePullSecrets` | `[]` | 拉取镜像的Secret。 | diff --git a/docs-2.0/nebula-operator/4.connect-to-nebula-graph-service.md b/docs-2.0/nebula-operator/4.connect-to-nebula-graph-service.md index b363ea9bc42..99befa7425e 100644 --- a/docs-2.0/nebula-operator/4.connect-to-nebula-graph-service.md +++ b/docs-2.0/nebula-operator/4.connect-to-nebula-graph-service.md @@ -25,12 +25,12 @@ 2. 使用上述`-graphd-svc` Service的IP连接Nebula Graph数据库: ```bash - kubectl run -ti --image vesoft/nebula-console:v2.5.0 --restart=Never -- -addr <10.98.213.34> -port 9669 -u -p + kubectl run -ti --image vesoft/nebula-console:{{console.branch}} --restart=Never -- -addr <10.98.213.34> -port 9669 -u -p ``` - `--image`:为连接Nebula Graph的工具Nebula Console的镜像。 - ``:自定义的Pod名称。 - - `-addr`:连接的Graphd服务的IP地址,即`ClusterIP`类型的Service IP地址。 + - `-addr`:连接Graphd服务的IP地址,即`ClusterIP`类型的Service IP地址。 - `-port`:连接Graphd服务的端口。默认端口为9669。 - `-u`:Nebula Graph账号的用户名。未启用身份认证时,可以使用任意已存在的用户名(默认为root)。 - `-p`:用户名对应的密码。未启用身份认证时,密码可以填写任意字符。 @@ -46,7 +46,7 @@ 用户还可以使用**完全限定域名(FQDN)**连接数据库,域名格式为`-graphd..svc.`: ```bash -kubectl run -ti --image vesoft/nebula-console:v2.5.0 --restart=Never -- -addr -graphd-svc.default.svc.cluster.local -port 9669 -u root -p vesoft +kubectl run -ti --image vesoft/nebula-console:{{console.branch}} --restart=Never -- -addr -graphd-svc.default.svc.cluster.local -port 9669 -u root -p vesoft ``` `CLUSTER_DOMAIN`的默认值为`cluster.local`。 @@ -120,13 +120,13 @@ kubectl run -ti --image vesoft/nebula-console:v2.5.0 --restart=Never -- -addr -port -u root -p vesoft + kubectl run -ti --image vesoft/nebula-console:{{console.branch}} --restart=Never -- -addr -port -u root -p vesoft ``` 示例如下: ```bash - [root@k8s4 ~]# kubectl run -ti --image vesoft/nebula-console:v2.5.0 --restart=Never -- nebula-console2 -addr 192.168.8.24 -port 32236 -u root -p vesoft + [root@k8s4 ~]# kubectl run -ti --image vesoft/nebula-console:{{console.branch}} --restart=Never -- nebula-console2 -addr 192.168.8.24 -port 32236 -u root -p vesoft If you don't see a command prompt, try pressing enter. (root@nebula) [(none)]> @@ -137,4 +137,4 @@ kubectl run -ti --image vesoft/nebula-console:v2.5.0 --restart=Never -- -storaged-2 Pod`。 +2. 待所有Pods都处于`Running`状态时,模拟故障,删除名为`-storaged-2` Pod。 ```bash kubectl delete pod -storaged-2 --now diff --git a/docs-2.0/nebula-spark-connector.md b/docs-2.0/nebula-spark-connector.md index 8c706297a43..297d0a38a24 100644 --- a/docs-2.0/nebula-spark-connector.md +++ b/docs-2.0/nebula-spark-connector.md @@ -10,7 +10,7 @@ Nebula Spark Connector是一个Spark连接器,提供通过Spark标准形式读 提供一个Spark SQL接口,用户可以使用该接口编程将DataFrame格式的数据逐条或批量写入Nebula Graph。 -更多使用说明请参见[Nebula Spark Connector](https://github.com/vesoft-inc/nebula-spark-utils/blob/{{sparkconnector.branch}}/nebula-spark-connector/README_CN.md)。 +更多使用说明请参见[Nebula Spark Connector](https://github.com/vesoft-inc/nebula-spark-connector/blob/{{sparkconnector.branch}}/README_CN.md)。 ## 适用场景 @@ -38,7 +38,7 @@ Nebula Spark Connector {{sparkconnector.release}}版本特性如下: - 统一了SparkSQL的扩展数据源,统一采用DataSourceV2进行Nebula Graph数据扩展。 -- 支持`insert`和`update`两种写入模式。`insert`模式会插入(覆盖)数据,`update`模式仅会更新已存在的数据。 +- 支持`insert`、`update`和`delete`三种写入模式。`insert`模式会插入(覆盖)数据,`update`模式仅会更新已存在的数据,`delete`模式只删除数据。 ## 获取Nebula Spark Connector @@ -48,16 +48,16 @@ Nebula Spark Connector {{sparkconnector.release}}版本特性如下: 安装 Spark 2.3以上版本。 -1. 克隆仓库`nebula-spark-utils`。 +1. 克隆仓库`nebula-spark-connector`。 ```bash - $ git clone -b {{sparkconnector.branch}} https://github.com/vesoft-inc/nebula-spark-utils.git + $ git clone -b {{sparkconnector.branch}} https://github.com/vesoft-inc/nebula-spark-connector.git ``` 2. 进入目录`nebula-spark-connector`。 ```bash - $ cd nebula-spark-utils/nebula-spark-connector + $ cd nebula-spark-connector/nebula-spark-connector ``` 3. 编译打包。 @@ -66,7 +66,7 @@ Nebula Spark Connector {{sparkconnector.release}}版本特性如下: $ mvn clean package -Dmaven.test.skip=true -Dgpg.skip -Dmaven.javadoc.skip=true ``` -编译完成后,在目录`nebula-spark-connector/target`下生成类似文件`nebula-spark-connector-{{sparkconnector.release}}-SHANPSHOT.jar`。 +编译完成后,在目录`nebula-spark-connector/nebula-spark-connector/target/`下生成类似文件`nebula-spark-connector-{{sparkconnector.release}}-SHANPSHOT.jar`。 ### Maven远程仓库下载 diff --git a/docs-2.0/nebula-studio/about-studio/st-ug-check-updates.md b/docs-2.0/nebula-studio/about-studio/st-ug-check-updates.md index a35ea711b83..c212a71a37d 100644 --- a/docs-2.0/nebula-studio/about-studio/st-ug-check-updates.md +++ b/docs-2.0/nebula-studio/about-studio/st-ug-check-updates.md @@ -12,5 +12,5 @@ Studio 处于持续开发状态中。用户可以通过 [Studio 发布版本更 成功连接 Studio 后,用户可以在页面右上角点击版本号,再点击 **新发布**,前往查看 Studio 的版本更新记录。 -![在页面右上角点击版本号,并在弹出菜单里点击“新发布”](../figs/st-ug-014-2.png "查看 Studio 版本更新记录") +![在页面右上角点击版本号,并在弹出菜单里点击“新发布”](../figs/st-ug-014.png "查看 Studio 版本更新记录") diff --git a/docs-2.0/nebula-studio/about-studio/st-ug-limitations.md b/docs-2.0/nebula-studio/about-studio/st-ug-limitations.md index 5f2694c1bdb..f3fff261ec5 100644 --- a/docs-2.0/nebula-studio/about-studio/st-ug-limitations.md +++ b/docs-2.0/nebula-studio/about-studio/st-ug-limitations.md @@ -12,7 +12,8 @@ | --- | --- | | 1.x | 1.x| | 2.0 & 2.0.1 | 2.x | -| 2.5.0 | 3.0.0 | +| 2.5.0 & 2.5.1 | 3.0.0 | +| 2.6.0 | 3.1.0 | ## 系统架构 diff --git a/docs-2.0/nebula-studio/about-studio/st-ug-release-note.md b/docs-2.0/nebula-studio/about-studio/st-ug-release-note.md index 77987c2e08d..a299368d5bc 100644 --- a/docs-2.0/nebula-studio/about-studio/st-ug-release-note.md +++ b/docs-2.0/nebula-studio/about-studio/st-ug-release-note.md @@ -1,7 +1,25 @@ # Studio版本更新说明 + +## v3.1.0(2021.10.29) + +- 功能增强: + - 适配 Nebula 2.6.0。 + - 新增在 Kubernetes 集群里使用 Helm 部署并启动 Studio。 + - 新增 GEO 数据类型。 + - 图探索 + - 新增配置节点图标功能。 + +- 修复: + - Schema + - 修复以关键字命名的 Tag/Edge 或其下属性时会报错的问题。 + - 修复数据类型不完善的问题,补充 date/time/datetime/int32/int16/int8 等类型枚举。 + +- 兼容: + - 去除 Studio 对 nebula-importer 的依赖,用 http-gateway 兼容相关功能。 + ## v3.0.0(2021.08.13) - 功能增强: - - 适配 Nebula 2.5.0 - - 配置 Schema 中支持给 Space、Tag、Edge Type、Index 添加 COMMENT + - 适配 Nebula 2.5.0。 + - 配置 Schema 中支持给 Space、Tag、Edge Type、Index 添加 COMMENT。 diff --git a/docs-2.0/nebula-studio/about-studio/st-ug-what-is-graph-studio.md b/docs-2.0/nebula-studio/about-studio/st-ug-what-is-graph-studio.md index 5ba7034aff8..f82382789f3 100644 --- a/docs-2.0/nebula-studio/about-studio/st-ug-what-is-graph-studio.md +++ b/docs-2.0/nebula-studio/about-studio/st-ug-what-is-graph-studio.md @@ -4,17 +4,18 @@ Nebula Graph Studio(简称 Studio)是一款可以通过 Web 访问的图数 ## 发行版本 -Studio 目前有三个发行版本: +可以使用以下四种方式安装部署 Studio: - Docker 版本:用户可以使用 Docker 服务部署 Studio,并连接到 Nebula Graph 数据库。详细信息参考 [Docker 部署 Studio](../deploy-connect/st-ug-deploy.md)。 - RPM 版本:用户可以使用 RPM 服务部署 Studio,并连接到 Nebula Graph 数据库。详细信息参考 [RPM 部署 Studio](../deploy-connect/st-ug-deploy.md)。 - tar 包安装部署:用户可以使用 tar 包安装并部署 Studio,并连接到 Nebula Graph 数据库。详细信息参考 [tar 包部署 Studio](../deploy-connect/st-ug-deploy.md)。 +- 使用 Helm 安装部署:在 Kubernetes 集群里使用 Helm 安装并部署 Studio,并连接到 Nebula Graph 数据库。详细信息参考 [使用 Helm 部署 Nebula Graph Studio](../deploy-connect/st-ug-deploy-by-helm.md)。 -三个发行版本功能基本相同,在使用 Studio 时可能会受到限制。详细信息,参考 [使用限制](st-ug-limitations.md)。 +四种部署方式功能基本相同,在使用 Studio 时可能会受到限制。详细信息,参考 [使用限制](st-ug-limitations.md)。 ## 产品功能 diff --git a/docs-2.0/nebula-studio/deploy-connect/st-ug-deploy-by-helm.md b/docs-2.0/nebula-studio/deploy-connect/st-ug-deploy-by-helm.md new file mode 100644 index 00000000000..75262fafb16 --- /dev/null +++ b/docs-2.0/nebula-studio/deploy-connect/st-ug-deploy-by-helm.md @@ -0,0 +1,66 @@ +# 使用 Helm 部署 Studio + +本文介绍如何在通过 Kubernetes 集群里用 Helm 来部署并启动 Studio。 + +## 前提条件 + +安装 Studio 前,用户需要安装以下软件并确保安装版本的正确性: + +| 软件 | 版本要求 | +| ------------------------------------------------------------ | --------- | +| [Kubernetes](https://kubernetes.io) | \>= 1.14 | +| [Helm](https://helm.sh) | \>= 3.2.0 | + +## 安装 + +1. 克隆 Studio 的源代码到主机。 + + ```bash + $ git clone https://github.com/vesoft-inc/nebula-studio.git + ``` + +2. 进入`nebula-studio`目录。 + + ```bash + $ cd nebula-studio + ``` + +3. 安装 Studio 到 Helm Chart,命名为 `my-studio`。 + + ```bash + $ helm upgrade --install my-studio --set service.type=NodePort --set service.port=30070 deployment/helm + ``` + +4. 启动成功后,在浏览器地址栏输入 `http://address-of-node:30070/`。 + 如果在浏览器窗口中能看到以下登录界面,表示已经成功部署并启动 Studio。 + + ![Nebula Graph Studio 登录界面](../figs/st-ug-001-1.png "Nebula Graph Studio 登录界面") + +## 卸载 + +```bash +$ helm uninstall my-studio +``` + +## 后续操作 + +进入 Studio 登录界面后,用户需要连接 Nebula Graph。详细信息,参考[连接数据库](st-ug-connect.md)。 + +## Nebula Graph Studio Chart配置参数说明 + +| 参数 | 默认值 | 描述 | +|:---|:---|:---| +| replicaCount | 0 | Deployment的副本数。 | +| image.httpGateway.name | vesoft/nebula-http-gateway | nebula-http-gateway 镜像的仓库地址。 | +| image.nebulaStudio.name | vesoft/nebula-graph-studio | nebula-graph-studio 镜像的仓库地址。 | +| image.nginx.name | nginx | nginx 镜像的仓库地址。 | +| image.httpGateway.version | v2.1.1 | nebula-http-gateway 的版本。 | +| image.nebulaStudio.version | v3.1.0 | nebula-graph-studio 的版本。 | +| image.nginx.version | alpine | nginx 的版本。 | +| service.type | ClusterIP | 服务类型,必须为`NodePort`,`ClusterIP`或`LoadBalancer`其中之一。 | +| service.port | 7001 | nebula-graph-studio 中 web 服务的端口。 | +| resources.httpGateway | {} | nebula-http-gateway 的资源限制/请求。 | +| resources.nebulaStudio | {} | nebula-studio的资源限制/请求。 | +| resources.nginx | {} | nginx 的资源限制/请求。 | +| persistent.storageClassName | "" | storageClass名称,如果不指定就使用默认值。 | +| persistent.size | 5Gi | 存储盘大小。 | diff --git a/docs-2.0/nebula-studio/deploy-connect/st-ug-deploy.md b/docs-2.0/nebula-studio/deploy-connect/st-ug-deploy.md index 0909aa5cf65..fcc9255ef12 100644 --- a/docs-2.0/nebula-studio/deploy-connect/st-ug-deploy.md +++ b/docs-2.0/nebula-studio/deploy-connect/st-ug-deploy.md @@ -35,7 +35,6 @@ Nebula Graph Studio( 以下简称 Studio )支持云端或本地部署。云 | ---- | ---- | | 7001 | Studio提供web服务使用。 | | 8080 | Nebula HTTP Gateway Client进行HTTP通信使用。 | - | 5699 | Nebula Importer导入数据导入使用。 | ### 安装 @@ -43,14 +42,14 @@ Nebula Graph Studio( 以下简称 Studio )支持云端或本地部署。云 | 安装包 | 检验和 | Nebula版本 | | ----- | ----- | ----- | - | [nebula-graph-studio-{{studio.release}}-1.x86_64.rpm](https://oss-cdn.nebula-graph.com.cn/nebula-graph-studio/{{studio.release}}/nebula-graph-studio-{{studio.release}}-1.x86_64.rpm) | [nebula-graph-studio-{{studio.release}}-1.x86_64.rpm.sha256](https://oss-cdn.nebula-graph.com.cn/nebula-graph-studio/{{studio.release}}/nebula-graph-studio-{{studio.release}}-1.x86_64.rpm.sha256) | {{ nebula.release }} | + | [nebula-graph-studio-{{studio.release}}.x86_64.rpm](https://oss-cdn.nebula-graph.com.cn/nebula-graph-studio/{{studio.release}}/nebula-graph-studio-{{studio.release}}.x86_64.rpm) | [nebula-graph-studio-{{studio.release}}.x86_64.rpm.sha256](https://oss-cdn.nebula-graph.com.cn/nebula-graph-studio/{{studio.release}}/nebula-graph-studio-{{studio.release}}.x86_64.rpm.sha256) | {{ nebula.release }} | 2. 使用`sudo rpm -i `命令安装RPM包。 例如,安装Studio {{studio.release}} 版本需要运行以下命令: ```bash - $ sudo rpm -i nebula-graph-studio-{{studio.release}}-1.x86_64.rpm + $ sudo rpm -i nebula-graph-studio-{{studio.release}}.x86_64.rpm ``` 当屏幕返回以下信息时,表示 PRM 版 Studio 已经成功启动。 @@ -58,8 +57,6 @@ Nebula Graph Studio( 以下简称 Studio )支持云端或本地部署。云 ```bash egg started on http://0.0.0.0:7001 nohup: 把输出追加到"nohup.out" - --- START OF NEBULA IMPORTER --- - [INFO] httpserver.go:80: Starting http server on 5699 ``` @@ -74,7 +71,7 @@ Nebula Graph Studio( 以下简称 Studio )支持云端或本地部署。云 用户可以使用以下的命令卸载 Studio。 ```bash -$ sudo rpm -e nebula-graph-studio-{{studio.release}}-1.x86_64 +$ sudo rpm -e nebula-graph-studio-{{studio.release}}.x86_64 ``` ### 异常处理 @@ -83,12 +80,12 @@ $ sudo rpm -e nebula-graph-studio-{{studio.release}}-1.x86_64 - 手动启动服务 ```bash -$ bash /usr/local/nebula-graph-studio/scripts/start.sh +$ bash /usr/local/nebula-graph-studio/scripts/rpm/start.sh ``` - 手动停止服务 ```bash -$ bash /usr/local/nebula-graph-studio/scripts/stop.sh +$ bash /usr/local/nebula-graph-studio/scripts/rpm/stop.sh ``` 如果启动服务时遇到报错报错 ERROR: bind EADDRINUSE 0.0.0.0:7001,用户可以通过以下命令查看端口7001是否被占用。 @@ -131,7 +128,6 @@ $ npm run start | ---- | ---- | | 7001 | Studio提供的web服务 | | 8080 | Nebula-http-gateway,Client的HTTP服务 | - | 5699 | Nebula importer文件导入工具,数据导入服务 | ### 安装 @@ -139,42 +135,39 @@ $ npm run start | 安装包 | Studio 版本 | | --- | --- | - | [nebula-graph-studio-{{studio.release}}-1.x86_64.tar.gz](https://oss-cdn.nebula-graph.com.cn/nebula-graph-studio/{{studio.release}}/nebula-graph-studio-{{studio.release}}-1.x86_64.tar.gz) | {{studio.release}} | + | [nebula-graph-studio-{{studio.release}}.x86_64.tar.gz](https://oss-cdn.nebula-graph.com.cn/nebula-graph-studio/{{studio.release}}/nebula-graph-studio-{{studio.release}}.x86_64.tar.gz) | {{studio.release}} | 2. 使用 `tar -xvf` 解压 tar 包。 ```bash - tar -xvf nebula-graph-studio-{{studio.release}}-1.x86_64.tar.gz + tar -xvf nebula-graph-studio-{{studio.release}}.x86_64.tar.gz ``` ### 部署 !!! Note - 根目录 nebula-graph-studio 下一共有三安装包:nebula-graph-studio,nebula-importer 和 nebula-http-gateway。用户需要在同一台机器上分别部署并启动服务,才能完成 Studio 的部署。 + 根目录 nebula-graph-studio 下一共有两个安装包:nebula-graph-studio 和 nebula-http-gateway。用户需要在同一台机器上分别部署并启动服务,才能完成 Studio 的部署。 -1. 部署 nebula-importer 并启动。 - - ```bash - $ cd nebula-importer - $ ./nebula-importer --port 5699 --callback "http://0.0.0.0:7001/api/import/finish" & - ``` - -2. 部署 nebula-http-gateway 并启动。 +1. 部署 nebula-http-gateway 并启动。 ```bash $ cd nebula-http-gateway $ nohup ./nebula-httpd & ``` -3. 部署 nebula-graph-studio 并启动。 +2. 部署 nebula-graph-studio 并启动。 ```bash $ cd nebula-graph-studio $ npm run start ``` -4.启动成功后,在浏览器地址栏输入 `http://ip address:7001`。 + !!! caution + + Studio {{studio.release}} 版本不需要依赖于 nebula-importer,故安装部署方式与 Studio v3.0.0 不同。 + +3. 启动成功后,在浏览器地址栏输入 `http://ip address:7001`。 如果在浏览器窗口中能看到以下登录界面,表示已经成功部署并启动 Studio。 @@ -185,7 +178,6 @@ $ npm run start 用户可以采用 `kill pid` 的方式来关停服务: ```bash -$ kill $(lsof -t -i :5699) # stop nebula-importer $ kill $(lsof -t -i :8080) # stop nebula-http-gateway $ cd nebula-graph-studio $ npm run stop # stop nebula-graph-studio @@ -205,7 +197,6 @@ $ npm run stop # stop nebula-graph-studio | ---- | ---- | | 7001 | Studio提供的web服务 | | 8080 | Nebula-http-gateway,Client的HTTP服务 | - | 5699 | Nebula importer文件导入工具,数据导入服务 | - (可选)在中国大陆从 Docker Hub 拉取 Docker 镜像的速度可能比较慢,用户可以使用 `registry-mirrors` 参数配置加速镜像。例如,如果要使用 Docker 中国区官方镜像、网易镜像和中国科技大学的镜像,则按以下格式配置 `registry-mirrors` 参数: @@ -229,18 +220,18 @@ $ npm run stop # stop nebula-graph-studio | 安装包 | Nebula Graph版本 | | ----- | ----- | - | [nebula-graph-studio-v3.tar.gz](https://oss-cdn.nebula-graph.com.cn/nebula-graph-studio/nebula-graph-studio-v3.tar.gz) | {{nebula.release}} | + | [nebula-graph-studio-v{{studio.release}}.tar.gz](https://oss-cdn.nebula-graph.com.cn/nebula-graph-studio/nebula-graph-studio-v{{studio.release}}.tar.gz) | {{nebula.release}} | -2. 创建`nebula-graph-studio-v3`目录,并将安装包解压至目录中。 +2. 创建`nebula-graph-studio-v{{studio.release}}`目录,并将安装包解压至目录中。 ```bash - mkdir nebula-graph-studio-v3 && tar -zxvf nebula-graph-studio-v3.tar.gz -C nebula-graph-studio-v3 + mkdir nebula-graph-studio-v{{studio.release}} && tar -zxvf nebula-graph-studio-v{{studio.release}}.tar.gz -C nebula-graph-studio-v{{studio.release}} ``` -3. 解压后进入 `nebula-graph-studio-v3` 目录。 +3. 解压后进入 `nebula-graph-studio-v{{studio.release}}` 目录。 ```bash - cd nebula-graph-studio-v3 + cd nebula-graph-studio-v{{studio.release}} ``` 4. 拉取 Studio 的 Docker 镜像。 @@ -258,7 +249,6 @@ $ npm run stop # stop nebula-graph-studio 当屏幕返回以下信息时,表示 Docker 版 Studio 已经成功启动。 ```bash - Creating docker_importer_1 ... done Creating docker_client_1 ... done Creating docker_web_1 ... done Creating docker_nginx_1 ... done diff --git a/docs-2.0/nebula-studio/figs/st-ug-014.png b/docs-2.0/nebula-studio/figs/st-ug-014.png index 707d0158ddd..b8a601ab1e9 100644 Binary files a/docs-2.0/nebula-studio/figs/st-ug-014.png and b/docs-2.0/nebula-studio/figs/st-ug-014.png differ diff --git a/docs-2.0/nebula-studio/figs/st-ug-046.png b/docs-2.0/nebula-studio/figs/st-ug-046.png index 21f3e434fba..32f7e529105 100644 Binary files a/docs-2.0/nebula-studio/figs/st-ug-046.png and b/docs-2.0/nebula-studio/figs/st-ug-046.png differ diff --git a/docs-2.0/nebula-studio/use-console/st-ug-open-in-explore.md b/docs-2.0/nebula-studio/use-console/st-ug-open-in-explore.md index e58ef4f3ef3..ffeb8e77cc1 100644 --- a/docs-2.0/nebula-studio/use-console/st-ug-open-in-explore.md +++ b/docs-2.0/nebula-studio/use-console/st-ug-open-in-explore.md @@ -30,7 +30,7 @@ Studio v{{ studio.release }} 及以后版本。请更新版本,详细操作参 查询语句示例如下: ```nGQL - nebula> GO FROM "player102" OVER serve YIELD serve._src,serve._dst; + nebula> GO FROM "player102" OVER serve YIELD src(edge),dst(edge); ``` 查询结果可以看到 `playerId` 为 `palyer102` 的球员服务球队的起始年份及终止年份。如下图所示。 @@ -81,7 +81,7 @@ Studio v{{ studio.release }} 及以后版本。请更新版本,详细操作参 查询语句示例如下: ```nGQL - nebula> FETCH PROP ON player "player100" YIELD player.name; + nebula> FETCH PROP ON player "player100" YIELD properties(vertex).name; ``` 查询得到 `playerId` 为 `player100` 的球员信息。如下图所示。 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 8da412e697b..823d369e5b6 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 @@ -48,9 +48,9 @@ Studio v{{ studio.release }} 及以后版本。请更新版本,详细操作参 - **清除插入**:清除画图板上原来的数据后,再插入新的数据。 -数据插入成功后,用户可以看到查询结果的可视化表现。 +数据插入成功后,用户可以看到查询结果的可视化表现。并支持在页面中,完成点的拓展、移动画布、修改点的颜色及icon、显示点边属性等操作。 -![在画布上显示返回的路径结果](../figs/st-ug-046-1.png "路径结果的可视化表现") +![在画布上显示返回的路径结果](../figs/st-ug-046.png "路径结果的可视化表现") ## 后续操作 diff --git a/docs-2.0/reuse/assets-1.png b/docs-2.0/reuse/assets-1.png new file mode 100644 index 00000000000..b84bb1ae10c Binary files /dev/null and b/docs-2.0/reuse/assets-1.png differ diff --git a/docs-2.0/reuse/assets.png b/docs-2.0/reuse/assets.png deleted file mode 100644 index f0dba0f5374..00000000000 Binary files a/docs-2.0/reuse/assets.png and /dev/null differ diff --git a/docs-2.0/reuse/assets260.png b/docs-2.0/reuse/assets260.png new file mode 100644 index 00000000000..c7ee1e27935 Binary files /dev/null and b/docs-2.0/reuse/assets260.png differ diff --git a/docs-2.0/reuse/console-1.png b/docs-2.0/reuse/console-1.png new file mode 100644 index 00000000000..921cb397877 Binary files /dev/null and b/docs-2.0/reuse/console-1.png differ diff --git a/docs-2.0/reuse/console.png b/docs-2.0/reuse/console.png deleted file mode 100644 index 3f08d4ba19b..00000000000 Binary files a/docs-2.0/reuse/console.png and /dev/null differ diff --git a/docs-2.0/reuse/console260.png b/docs-2.0/reuse/console260.png new file mode 100644 index 00000000000..987ae8f766b Binary files /dev/null and b/docs-2.0/reuse/console260.png differ 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 d0552c19abf..560d5f64846 100644 --- a/docs-2.0/reuse/source_connect-to-nebula-graph.md +++ b/docs-2.0/reuse/source_connect-to-nebula-graph.md @@ -24,11 +24,11 @@ Nebula Graph支持多种类型客户端,包括CLI客户端、GUI客户端和 建议选择**最新**版本。 - ![Select a Nebula Graph version and click **Assets**](../reuse/console.png "Click Assets to show the available Nebula Graph binary files") + ![Select a Nebula Graph version and click **Assets**](../reuse/console260.png "Click Assets to show the available Nebula Graph binary files") 2. 在**Assets**区域找到机器运行所需的二进制文件,下载文件到机器上。 - ![Click to download the package according to your hardware architecture](../reuse/assets.png "Click the package name to download it") + ![Click to download the package according to your hardware architecture](../reuse/assets260.png "Click the package name to download it") 3. (可选)为方便使用,重命名文件为`nebula-console`。 @@ -77,7 +77,7 @@ Nebula Graph支持多种类型客户端,包括CLI客户端、GUI客户端和 | `-e/-eval` | 设置字符串类型的nGQL语句。连接成功后会执行一次该语句并返回结果,然后自动断开连接。 | | `-f/-file` | 设置存储nGQL语句的文件的路径。连接成功后会执行该文件内的nGQL语句并返回结果,执行完毕后自动断开连接。 | -用户可以使用`./nebula-console --help`命令获取所有参数的说明,也可以在[项目仓库](https://github.com/vesoft-inc/nebula-console/tree/v2.0.0-ga)找到更多说明。 +用户可以使用`./nebula-console --help`命令获取所有参数的说明,也可以在[项目仓库](https://github.com/vesoft-inc/nebula-console/tree/{{console.branch}})找到更多说明。 ## Nebula Console命令 @@ -89,6 +89,8 @@ Nebula Console提供部分命令,可以导出CSV文件、导出DOT文件、导 ### 导出CSV文件 +CSV文件用于保存命令执行的返回结果。 + !!! note - CSV文件保存在当前工作目录中,即Linux命令`pwd`显示的目录。 @@ -103,6 +105,8 @@ nebula> :CSV ### 导出DOT文件 +DOT文件同样用于保存命令执行的返回结果,其保存的结果信息和CSV文件不同。 + !!! Note - DOT文件保存在当前工作目录中,即Linux命令`pwd`显示的目录。 @@ -151,7 +155,6 @@ nebula> GO FROM "player100" OVER follow; | follow._dst | +-------------+ | "player101" | -+-------------+ | "player125" | +-------------+ Got 2 rows (time spent 2602/3214 us) @@ -162,7 +165,6 @@ Fri, 20 Aug 2021 06:36:05 UTC | follow._dst | +-------------+ | "player101" | -+-------------+ | "player125" | +-------------+ Got 2 rows (time spent 583/849 us) @@ -173,7 +175,6 @@ Fri, 20 Aug 2021 06:36:05 UTC | follow._dst | +-------------+ | "player101" | -+-------------+ | "player125" | +-------------+ Got 2 rows (time spent 496/671 us) diff --git a/docs-2.0/reuse/source_install-nebula-graph-by-rpm-or-deb.md b/docs-2.0/reuse/source_install-nebula-graph-by-rpm-or-deb.md index de13ae06264..c5f83a97178 100644 --- a/docs-2.0/reuse/source_install-nebula-graph-by-rpm-or-deb.md +++ b/docs-2.0/reuse/source_install-nebula-graph-by-rpm-or-deb.md @@ -2,7 +2,7 @@ RPM和DEB是Linux系统下常见的两种安装包格式,本文介绍如何使 !!! note - 部署Nebula Graph集群的方式参见[使用RPM/DEB包部署集群](https://docs.nebula-graph.com.cn/{{nebula.release}}/4.deployment-and-installation/1.resource-preparations/)。 + 部署Nebula Graph集群的方式参见[使用RPM/DEB包部署集群](https://docs.nebula-graph.com.cn/{{nebula.release}}/4.deployment-and-installation/deploy-nebula-graph-cluster/)。 !!! enterpriseonly @@ -115,15 +115,27 @@ RPM和DEB是Linux系统下常见的两种安装包格式,本文介绍如何使 - 安装RPM包 - ```bash - $ sudo rpm -ivh --prefix= - ``` + ```bash + $ sudo rpm -ivh --prefix= + ``` + + 例如在默认路径下安装{{nebula.release}}版本的RPM包: + + ```bash + sudo rpm -ivh nebula-graph-{{nebula.release}}.el7.x86_64.rpm + ``` - 安装DEB包 - ```bash - $ sudo dpkg -i --instdir== - ``` + ```bash + $ sudo dpkg -i --instdir== + ``` + + 例如在默认路径下安装{{nebula.release}}版本的DEB包: + + ```bash + sudo dpkg -i nebula-graph-{{nebula.release}}.ubuntu1804.amd64.deb + ``` !!! Note diff --git a/docs-2.0/reuse/source_manage-service.md b/docs-2.0/reuse/source_manage-service.md index c82a0724730..ebc957ea26f 100644 --- a/docs-2.0/reuse/source_manage-service.md +++ b/docs-2.0/reuse/source_manage-service.md @@ -124,9 +124,9 @@ $ sudo /usr/local/nebula/scripts/nebula.service status all - 如果返回如下结果,表示Nebula Graph服务正常运行。 ```bash - [INFO] nebula-metad: Running as 26601, Listening on 9559 - [INFO] nebula-graphd: Running as 26644, Listening on 9669 - [INFO] nebula-storaged: Running as 26709, Listening on 9779 + [INFO] nebula-metad(3ba41bd): Running as 26601, Listening on 9559 + [INFO] nebula-graphd(3ba41bd): Running as 26644, Listening on 9669 + [INFO] nebula-storaged(3ba41bd): Running as 26709, Listening on 9779 ``` - 如果返回类似如下结果,表示Nebula Graph服务异常,可以根据异常服务信息进一步排查,或者在[Nebula Graph社区](https://discuss.nebula-graph.com.cn/)寻求帮助。 diff --git a/mkdocs.yml b/mkdocs.yml index 5c935e9ae89..3a41eb5bf03 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,32 +1,25 @@ -<<<<<<< HEAD # Project information site_name: 开源分布式图数据库 Nebula Graph 完全指南 site_description: Nebula Graph Database -site_author: 吴敏,周瑶,梁振亚,杨怡璇 -======= -site_name: Nebula Graph Database 手册 -site_description: Documentation for Nebula Graph Database -site_author: Nebula Graph -site_url: https://docs.nebula-graph.com.cn/master/ -edit_uri: 'edit/master/docs-2.0/' ->>>>>>> master +site_author: 吴敏,周瑶,梁振亚,杨怡璇,黄凤仙 docs_dir: docs-2.0 # Configuration theme: name: 'material' + custom_dir: overrides logo: 'https://cloud-cdn.nebula-graph.com.cn/vesoft-nebula-logo-white.png' favicon: 'assets/images/favicon.ico' palette: - scheme: default - primary: teal - accent: light green + primary: lime + accent: green toggle: icon: material/toggle-switch-off-outline name: Switch to dark mode - scheme: slate - primary: deep orange - accent: red + primary: amber + accent: deep orange toggle: icon: material/toggle-switch name: Switch to light mode @@ -42,11 +35,12 @@ extra_css: - stylesheets/extra.css extra: nebula: - release: 2.5.1 - nightly: v2-nightly + release: 2.6.1 + nightly: nightly master: master base20: 2.0 base200: 2.0.0 + branch: v2.6.1 version: method: mike social: @@ -56,28 +50,28 @@ extra: base111b: 1.1.1-beta base220: 2.2.1 base300: 3.0.0 - release: 3.0.0 + release: 3.1.0 explorer: base100: 1.0.0 release: 2.0.0 exchange: - release: 2.5.0 - branch: v2.5 + release: 2.6.0 + branch: v2.6.0 importer: - release: 2.5.0 - branch: release-v2.0.0-ga + release: 2.6.0 + branch: v2.6.0 algorithm: - release: 2.5.0 + release: 2.5.1 branch: v2.5 sparkconnector: - release: 2.5.0 - branch: v2.5 + release: 2.6.0 + branch: v2.6 flinkconnector: - release: 2.5.0 - branch: v2.5 + release: 2.6.0 + branch: v2.6 dockercompose: - release: 2.5.0 - branch: v2.5.0 + release: 2.6.0 + branch: v2.6.0 common: release: 2.5.0 dashboard: @@ -85,21 +79,22 @@ extra: base100: 1.0.0 branch: v1.0.1 console: - release: 2.5.0 + release: 2.6.0 + branch: v2.6.0 br: release: 0.5.0 cpp: release: 2.5.0 branch: v2.5.0 java: - release: 2.5.0 - branch: v2.5.0 + release: 2.6.0 + branch: v2.6.0 python: - release: 2.5.0 - branch: v2.5.0 + release: 2.6.0 + branch: v2.6.0 go: - release: 2.5.0 - branch: release-v2.5.0 + release: 2.6.0 + branch: v2.6.0 bench: release: 1.0.0 branch: master @@ -133,6 +128,7 @@ nav: - 步骤2:启动Nebula Graph: 2.quick-start/5.start-stop-service.md - 步骤3:连接Nebula Graph: 2.quick-start/3.connect-to-nebula-graph.md - 步骤4:使用常用命令: 2.quick-start/4.nebula-graph-crud.md + - nGQL命令汇总: 2.quick-start/6.cheatsheet-for-ngql-command.md - nGQL指南: - nGQL概述: @@ -153,6 +149,7 @@ nav: #- 集合: 3.ngql-guide/3.data-types/7.set.md - 映射: 3.ngql-guide/3.data-types/8.map.md - 类型转换: 3.ngql-guide/3.data-types/9.type-conversion.md + - 地理位置: 3.ngql-guide/3.data-types/10.geography.md - 变量和复合查询: - 复合查询: 3.ngql-guide/4.variable-and-composite-queries/1.composite-queries.md @@ -174,6 +171,7 @@ nav: - 字符串函数: 3.ngql-guide/6.functions-and-expressions/2.string.md - 日期时间函数: 3.ngql-guide/6.functions-and-expressions/3.date-and-time.md - Schema函数: 3.ngql-guide/6.functions-and-expressions/4.schema.md + - CASE表达式: 3.ngql-guide/6.functions-and-expressions/5.case-expressions.md - 列表函数: 3.ngql-guide/6.functions-and-expressions/6.list.md - count函数: 3.ngql-guide/6.functions-and-expressions/7.count.md - collect函数: 3.ngql-guide/6.functions-and-expressions/10.collect.md @@ -181,8 +179,8 @@ nav: - hash函数: 3.ngql-guide/6.functions-and-expressions/12.hash.md - concat函数: 3.ngql-guide/6.functions-and-expressions/13.concat.md - 谓词函数: 3.ngql-guide/6.functions-and-expressions/8.predicate.md + - geo函数: 3.ngql-guide/6.functions-and-expressions/14.geo.md - 自定义函数: 3.ngql-guide/6.functions-and-expressions/9.user-defined-functions.md - - CASE表达式: 3.ngql-guide/6.functions-and-expressions/5.case-expressions.md - 通用查询语句: - MATCH: 3.ngql-guide/7.general-query-statements/2.match.md @@ -212,6 +210,7 @@ nav: - 子句和选项: - GROUP BY: 3.ngql-guide/8.clauses-and-options/group-by.md - LIMIT and SKIP: 3.ngql-guide/8.clauses-and-options/limit.md + - SAMPLE: 3.ngql-guide/8.clauses-and-options/sample.md - ORDER BY: 3.ngql-guide/8.clauses-and-options/order-by.md - RETURN: 3.ngql-guide/8.clauses-and-options/return.md - TTL: 3.ngql-guide/8.clauses-and-options/ttl-options.md @@ -233,6 +232,8 @@ nav: - SHOW TAGS: 3.ngql-guide/10.tag-statements/4.show-tags.md - DESCRIBE TAG: 3.ngql-guide/10.tag-statements/5.describe-tag.md - DELETE TAG: 3.ngql-guide/10.tag-statements/6.delete-tag.md + - 增加和删除标签: 3.ngql-guide/10.tag-statements/improve-query-by-tag-index.md + - Edge type语句: - CREATE EDGE: 3.ngql-guide/11.edge-type-statements/1.create-edge.md - DROP EDGE: 3.ngql-guide/11.edge-type-statements/2.drop-edge.md @@ -287,13 +288,14 @@ nav: - 编译与安装: - 使用源码安装: 4.deployment-and-installation/2.compile-and-install-nebula-graph/1.install-nebula-graph-by-compiling-the-source-code.md - 使用RPM/DEB包安装: 4.deployment-and-installation/2.compile-and-install-nebula-graph/2.install-nebula-graph-by-rpm-or-deb.md + - 使用tar.gz文件安装: 4.deployment-and-installation/2.compile-and-install-nebula-graph/4.install-nebula-graph-from-tar.md - 使用Docker Compose部署: 4.deployment-and-installation/2.compile-and-install-nebula-graph/3.deploy-nebula-graph-with-docker-compose.md - - 使用RPM/DEB包部署集群: 4.deployment-and-installation/2.compile-and-install-nebula-graph/deploy-nebula-graph-cluster.md + - 使用RPM/DEB包部署多机集群: 4.deployment-and-installation/2.compile-and-install-nebula-graph/deploy-nebula-graph-cluster.md - 管理服务: 4.deployment-and-installation/manage-service.md - 连接服务: 4.deployment-and-installation/connect-to-nebula-graph.md - 升级版本: - - 升级历史版本至v2.5.0: 4.deployment-and-installation/3.upgrade-nebula-graph/upgrade-nebula-graph-to-250.md - - 升级v2.0.x至v2.5.0: 4.deployment-and-installation/3.upgrade-nebula-graph/upgrade-nebula-from-200-to-250.md + - 升级历史版本至v2.6.0: 4.deployment-and-installation/3.upgrade-nebula-graph/upgrade-nebula-graph-to-260.md + - 升级v2.0.x至v2.6.0: 4.deployment-and-installation/3.upgrade-nebula-graph/upgrade-nebula-from-200-to-260.md - 卸载Nebula Graph: 4.deployment-and-installation/4.uninstall-nebula-graph.md - 配置与日志: @@ -322,6 +324,8 @@ nav: # - 使用BR备份数据: 7.data-security/2.backup-restore/3.br-backup-data.md # - 使用BR恢复数据: 7.data-security/2.backup-restore/4.br-restore-data.md - 管理快照: 7.data-security/3.manage-snapshot.md + - Group&Zone: 7.data-security/5.zone.md + - SSL加密: 7.data-security/4.ssl.md - 最佳实践: - Compaction: 8.service-tuning/compaction.md @@ -351,6 +355,7 @@ nav: - 快捷键: nebula-studio/about-studio/st-ug-shortcuts.md - 安装与登录: - 部署 Studio: nebula-studio/deploy-connect/st-ug-deploy.md + - 使用 Helm 部署 Studio: nebula-studio/deploy-connect/st-ug-deploy-by-helm.md - 连接数据库: nebula-studio/deploy-connect/st-ug-connect.md - 清除连接: nebula-studio/deploy-connect/st-ug-reset-connection.md - 快速开始: @@ -373,26 +378,26 @@ nav: - 无法访问 Studio: nebula-studio/troubleshooting/st-ug-connection-errors.md - Studio 常见问题: nebula-studio/troubleshooting/st-ug-faq.md - - Nebula Dashboard: - - 什么是Nebula Dashboard: nebula-dashboard/1.what-is-dashboard.md - - 部署Dashboard: nebula-dashboard/2.deploy-dashboard.md - - 连接Dashboard: nebula-dashboard/3.connect-dashboard.md - - Dashboard页面介绍: nebula-dashboard/4.use-dashboard.md - - 监控指标说明: nebula-dashboard/6.monitor-parameter.md - - - Nebula Explorer: - - 什么是Nebula Explorer: nebula-explorer/about-explorer/ex-ug-what-is-explorer.md - - 安装与登录: - - 部署 Explorer: nebula-explorer/deploy-connect/ex-ug-deploy.md - - 连接数据库: nebula-explorer/deploy-connect/ex-ug-connect.md - - 清除连接: nebula-explorer/deploy-connect/ex-ug-reset-connection.md - - 操作指南: - - 页面概览: nebula-explorer/operation-guide/ex-ug-page-overview.md - - 查询探索: nebula-explorer/operation-guide/ex-ug-query-exploration.md - - 图探索拓展: nebula-explorer/operation-guide/ex-ug-graph-exploration.md - - 画布操作: nebula-explorer/operation-guide/ex-ug-canvas.md - - 关系列表: nebula-explorer/operation-guide/ex-ug-relationship-list.md - - 快捷键: nebula-explorer/operation-guide/ex-ug-shortcuts.md +# - Nebula Dashboard: +# - 什么是Nebula Dashboard: nebula-dashboard/1.what-is-dashboard.md +# - 部署Dashboard: nebula-dashboard/2.deploy-dashboard.md +# - 连接Dashboard: nebula-dashboard/3.connect-dashboard.md +# - Dashboard页面介绍: nebula-dashboard/4.use-dashboard.md +# - 监控指标说明: nebula-dashboard/6.monitor-parameter.md + +# - Nebula Explorer: +# - 什么是Nebula Explorer: nebula-explorer/about-explorer/ex-ug-what-is-explorer.md +# - 安装与登录: +# - 部署 Explorer: nebula-explorer/deploy-connect/ex-ug-deploy.md +# - 连接数据库: nebula-explorer/deploy-connect/ex-ug-connect.md +# - 清除连接: nebula-explorer/deploy-connect/ex-ug-reset-connection.md +# - 操作指南: +# - 页面概览: nebula-explorer/operation-guide/ex-ug-page-overview.md +# - 查询探索: nebula-explorer/operation-guide/ex-ug-query-exploration.md +# - 图探索拓展: nebula-explorer/operation-guide/ex-ug-graph-exploration.md +# - 画布操作: nebula-explorer/operation-guide/ex-ug-canvas.md +# - 关系列表: nebula-explorer/operation-guide/ex-ug-relationship-list.md +# - 快捷键: nebula-explorer/operation-guide/ex-ug-shortcuts.md - Nebula Importer: - 使用Nebula Importer: nebula-importer/use-importer.md @@ -423,16 +428,16 @@ nav: - 导入SST文件数据: nebula-exchange/use-exchange/ex-ug-import-from-sst.md - Exchange 常见问题: nebula-exchange/ex-ug-FAQ.md - - Nebula Operator: - - 什么是Nebula Operator: nebula-operator/1.introduction-to-nebula-operator.md - - 使用流程: nebula-operator/6.get-started-with-operator.md - - 部署Nebula Operator: nebula-operator/2.deploy-nebula-operator.md - - 部署Nebula Graph集群: - - 使用Kubectl部署Nebula Graph集群: nebula-operator/3.deploy-nebula-graph-cluster/3.1create-cluster-with-kubectl.md - - 使用Helm部署Nebula Graph集群: nebula-operator/3.deploy-nebula-graph-cluster/3.2create-cluster-with-helm.md - - 连接Nebula Graph数据库: nebula-operator/4.connect-to-nebula-graph-service.md - - 故障自愈: nebula-operator/5.operator-failover.md - - 常见问题: nebula-operator/7.operator-faq.md +# - Nebula Operator: +# - 什么是Nebula Operator: nebula-operator/1.introduction-to-nebula-operator.md +# - 使用流程: nebula-operator/6.get-started-with-operator.md +# - 部署Nebula Operator: nebula-operator/2.deploy-nebula-operator.md +# - 部署Nebula Graph集群: +# - 使用Kubectl部署Nebula Graph集群: nebula-operator/3.deploy-nebula-graph-cluster/3.1create-cluster-with-kubectl.md +# - 使用Helm部署Nebula Graph集群: nebula-operator/3.deploy-nebula-graph-cluster/3.2create-cluster-with-helm.md +# - 连接Nebula Graph数据库: nebula-operator/4.connect-to-nebula-graph-service.md +# - 故障自愈: nebula-operator/5.operator-failover.md +# - 常见问题: nebula-operator/7.operator-faq.md - Nebula Algorithm: nebula-algorithm.md @@ -482,9 +487,24 @@ plugins: - macros: include_dir: docs-2.0/reuse/ - git-revision-date-localized + + - exclude: +# Exclude files with unix-style wildcards (globs) + glob: +# Exclude all files in a directory. The path starts with the directory name in docs-2.0, such as `20.appendix/*`. + - 7.data-security/2.backup-restore/* + - nebula-flink/* + - CHANGELOG.md + - spark-connector/* +# Exclude the file with the following file name. +# - abc.md +# Exclude files with regular expressions (regexes) +# regex: +# - '.*\.(tmp|bin|tar)$' + - with-pdf: copyright: 2021 Vesoft Inc. - cover_subtitle: master since 2.5.1 + cover_subtitle: 2.6.1 author: 吴敏,周瑶,梁振亚,杨怡璇,黄凤仙 cover: true back_cover: true diff --git a/requirements.txt b/requirements.txt index e994d097eac..e09a155f4c6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,3 +8,4 @@ mkdocs-git-revision-date-localized-plugin weasyprint==52.5 mkdocs-with-pdf qrcode +mkdocs-exclude