diff --git a/content/cn/docs/clients/restful-api/_index.md b/content/cn/docs/clients/restful-api/_index.md index bd52c92fb..afdd9d830 100644 --- a/content/cn/docs/clients/restful-api/_index.md +++ b/content/cn/docs/clients/restful-api/_index.md @@ -4,8 +4,12 @@ linkTitle: "RESTful API" weight: 1 --- -HugeGraph-Server通过HugeGraph-API基于HTTP协议为Client提供操作图的接口,主要包括元数据和 -图数据的增删改查,遍历算法,变量,图操作及其他操作。 +> ⚠️ **版本兼容性说明** +> +> - HugeGraph 1.7.0+ 引入了图空间功能,API 路径格式为:`/graphspaces/{graphspace}/graphs/{graph}` +> - HugeGraph 1.5.x 及之前版本使用旧路径:`/graphs/{graph}`, 以及创建/克隆图的 api 使用 text/plain 作为 Content-Type, 1.7.0 及之后使用 json +> - 默认图空间名称为 `DEFAULT`,可直接使用 +> - 旧版本 doc 参考:[HugeGraph 1.5.x RESTful API](https://github.com/apache/incubator-hugegraph-doc/tree/release-1.5.0) 除了下方的文档,你还可以通过 `localhost:8080/swagger-ui/index.html` 访问 `swagger-ui` 以查看 `RESTful API`。[示例可以参考此处](/cn/docs/quickstart/hugegraph/hugegraph-server#swaggerui-example) diff --git a/content/cn/docs/clients/restful-api/auth.md b/content/cn/docs/clients/restful-api/auth.md index cee6c3091..606b4e5c0 100644 --- a/content/cn/docs/clients/restful-api/auth.md +++ b/content/cn/docs/clients/restful-api/auth.md @@ -22,6 +22,7 @@ city: Beijing}) ##### 接口说明: 用户认证与权限控制接口包括 5 类:UserAPI、GroupAPI、TargetAPI、BelongAPI、AccessAPI。 +**注意**: 1.5.0 及之前,group/target 等 id 的格式类似 -69:grant,1.7.0 及之后,id 和 name 一致,如 admin [HugeGraph 1.5.x RESTful API](https://github.com/apache/incubator-hugegraph-doc/tree/release-1.5.0) ### 10.2 用户(User)API 用户接口包括:创建用户,删除用户,修改用户,和查询用户相关信息接口。 @@ -52,7 +53,7 @@ city: Beijing}) ##### Method & Url ``` -POST http://localhost:8080/graphs/hugegraph/auth/users +POST http://localhost:8080/graphspaces/DEFAULT/auth/users ``` ##### Response Status @@ -71,7 +72,7 @@ POST http://localhost:8080/graphs/hugegraph/auth/users "user_name": "boss", "user_creator": "admin", "user_phone": "182****9088", - "id": "-63:boss", + "id": "boss", "user_create": "2020-11-17 14:31:07.833" } ``` @@ -86,7 +87,7 @@ POST http://localhost:8080/graphs/hugegraph/auth/users ##### Method & Url ``` -DELETE http://localhost:8080/graphs/hugegraph/auth/users/-63:test +DELETE http://localhost:8080/graphspaces/DEFAULT/auth/users/test ``` ##### Response Status @@ -110,7 +111,7 @@ DELETE http://localhost:8080/graphs/hugegraph/auth/users/-63:test ##### Method & Url ``` -PUT http://localhost:8080/graphs/hugegraph/auth/users/-63:test +PUT http://localhost:8080/graphspaces/DEFAULT/auth/users/test ``` ##### Request Body @@ -138,7 +139,7 @@ PUT http://localhost:8080/graphs/hugegraph/auth/users/-63:test "user_name": "test", "user_creator": "admin", "user_phone": "183****9266", - "id": "-63:test", + "id": "test", "user_create": "2020-11-12 10:27:13.601" } ``` @@ -153,7 +154,7 @@ PUT http://localhost:8080/graphs/hugegraph/auth/users/-63:test ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/auth/users +GET http://localhost:8080/graphspaces/DEFAULT/auth/users ``` ##### Response Status @@ -172,7 +173,7 @@ GET http://localhost:8080/graphs/hugegraph/auth/users "user_update": "2020-11-11 11:41:12.254", "user_name": "admin", "user_creator": "system", - "id": "-63:admin", + "id": "admin", "user_create": "2020-11-11 11:41:12.254" } ] @@ -188,7 +189,7 @@ GET http://localhost:8080/graphs/hugegraph/auth/users ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/auth/users/-63:admin +GET http://localhost:8080/graphspaces/DEFAULT/auth/users/admin ``` ##### Response Status @@ -207,7 +208,7 @@ GET http://localhost:8080/graphs/hugegraph/auth/users/-63:admin "user_update": "2020-11-11 11:41:12.254", "user_name": "admin", "user_creator": "system", - "id": "-63:admin", + "id": "admin", "user_create": "2020-11-11 11:41:12.254" } ] @@ -219,7 +220,7 @@ GET http://localhost:8080/graphs/hugegraph/auth/users/-63:admin ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/auth/users/-63:boss/role +GET http://localhost:8080/graphspaces/DEFAULT/auth/users/boss/role ``` ##### Response Status @@ -270,7 +271,7 @@ GET http://localhost:8080/graphs/hugegraph/auth/users/-63:boss/role ##### Method & Url ``` -POST http://localhost:8080/graphs/hugegraph/auth/groups +POST http://localhost:8080/graphspaces/DEFAULT/auth/groups ``` ##### Response Status @@ -302,7 +303,7 @@ POST http://localhost:8080/graphs/hugegraph/auth/groups ##### Method & Url ``` -DELETE http://localhost:8080/graphs/hugegraph/auth/groups/-69:grant +DELETE http://localhost:8080/graphspaces/DEFAULT/auth/groups/-69:grant ``` ##### Response Status @@ -326,7 +327,7 @@ DELETE http://localhost:8080/graphs/hugegraph/auth/groups/-69:grant ##### Method & Url ``` -PUT http://localhost:8080/graphs/hugegraph/auth/groups/-69:grant +PUT http://localhost:8080/graphspaces/DEFAULT/auth/groups/-69:grant ``` ##### Request Body @@ -366,7 +367,7 @@ PUT http://localhost:8080/graphs/hugegraph/auth/groups/-69:grant ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/auth/groups +GET http://localhost:8080/graphspaces/DEFAULT/auth/groups ``` ##### Response Status @@ -401,7 +402,7 @@ GET http://localhost:8080/graphs/hugegraph/auth/groups ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/auth/groups/-69:all +GET http://localhost:8080/graphspaces/DEFAULT/auth/groups/-69:all ``` ##### Response Status @@ -464,7 +465,7 @@ target_resources 可以包括多个 target_resource,以列表的形式存储 ##### Method & Url ``` -POST http://localhost:8080/graphs/hugegraph/auth/targets +POST http://localhost:8080/graphspaces/DEFAULT/auth/targets ``` ##### Response Status @@ -504,7 +505,7 @@ POST http://localhost:8080/graphs/hugegraph/auth/targets ##### Method & Url ``` -DELETE http://localhost:8080/graphs/hugegraph/auth/targets/-77:gremlin +DELETE http://localhost:8080/graphspaces/DEFAULT/auth/targets/-77:gremlin ``` ##### Response Status @@ -529,7 +530,7 @@ DELETE http://localhost:8080/graphs/hugegraph/auth/targets/-77:gremlin ##### Method & Url ``` -PUT http://localhost:8080/graphs/hugegraph/auth/targets/-77:gremlin +PUT http://localhost:8080/graphspaces/DEFAULT/auth/targets/-77:gremlin ``` ##### Request Body @@ -583,7 +584,7 @@ PUT http://localhost:8080/graphs/hugegraph/auth/targets/-77:gremlin ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/auth/targets +GET http://localhost:8080/graphspaces/DEFAULT/auth/targets ``` ##### Response Status @@ -642,7 +643,7 @@ GET http://localhost:8080/graphs/hugegraph/auth/targets ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/auth/targets/-77:grant +GET http://localhost:8080/graphspaces/DEFAULT/auth/targets/-77:grant ``` ##### Response Status @@ -688,7 +689,7 @@ GET http://localhost:8080/graphs/hugegraph/auth/targets/-77:grant ```json { - "user": "-63:boss", + "user": "boss", "group": "-69:all" } ``` @@ -697,7 +698,7 @@ GET http://localhost:8080/graphs/hugegraph/auth/targets/-77:grant ##### Method & Url ``` -POST http://localhost:8080/graphs/hugegraph/auth/belongs +POST http://localhost:8080/graphspaces/DEFAULT/auth/belongs ``` ##### Response Status @@ -713,8 +714,8 @@ POST http://localhost:8080/graphs/hugegraph/auth/belongs "belong_create": "2020-11-11 16:19:35.422", "belong_creator": "admin", "belong_update": "2020-11-11 16:19:35.422", - "id": "S-63:boss>-82>>S-69:all", - "user": "-63:boss", + "id": "Sboss>-82>>S-69:all", + "user": "boss", "group": "-69:all" } ``` @@ -728,7 +729,7 @@ POST http://localhost:8080/graphs/hugegraph/auth/belongs ##### Method & Url ``` -DELETE http://localhost:8080/graphs/hugegraph/auth/belongs/S-63:boss>-82>>S-69:grant +DELETE http://localhost:8080/graphspaces/DEFAULT/auth/belongs/Sboss>-82>>S-69:grant ``` ##### Response Status @@ -753,7 +754,7 @@ DELETE http://localhost:8080/graphs/hugegraph/auth/belongs/S-63:boss>-82>>S-69:g ##### Method & Url ``` -PUT http://localhost:8080/graphs/hugegraph/auth/belongs/S-63:boss>-82>>S-69:grant +PUT http://localhost:8080/graphspaces/DEFAULT/auth/belongs/Sboss>-82>>S-69:grant ``` ##### Request Body @@ -778,8 +779,8 @@ PUT http://localhost:8080/graphs/hugegraph/auth/belongs/S-63:boss>-82>>S-69:gran "belong_create": "2020-11-12 10:40:21.720", "belong_creator": "admin", "belong_update": "2020-11-12 10:42:47.265", - "id": "S-63:boss>-82>>S-69:grant", - "user": "-63:boss", + "id": "Sboss>-82>>S-69:grant", + "user": "boss", "group": "-69:grant" } ``` @@ -794,7 +795,7 @@ PUT http://localhost:8080/graphs/hugegraph/auth/belongs/S-63:boss>-82>>S-69:gran ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/auth/belongs +GET http://localhost:8080/graphspaces/DEFAULT/auth/belongs ``` ##### Response Status @@ -812,8 +813,8 @@ GET http://localhost:8080/graphs/hugegraph/auth/belongs "belong_create": "2020-11-11 16:19:35.422", "belong_creator": "admin", "belong_update": "2020-11-11 16:19:35.422", - "id": "S-63:boss>-82>>S-69:all", - "user": "-63:boss", + "id": "Sboss>-82>>S-69:all", + "user": "boss", "group": "-69:all" } ] @@ -829,7 +830,7 @@ GET http://localhost:8080/graphs/hugegraph/auth/belongs ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/auth/belongs/S-63:boss>-82>>S-69:all +GET http://localhost:8080/graphspaces/DEFAULT/auth/belongs/Sboss>-82>>S-69:all ``` ##### Response Status @@ -845,8 +846,8 @@ GET http://localhost:8080/graphs/hugegraph/auth/belongs/S-63:boss>-82>>S-69:all "belong_create": "2020-11-11 16:19:35.422", "belong_creator": "admin", "belong_update": "2020-11-11 16:19:35.422", - "id": "S-63:boss>-82>>S-69:all", - "user": "-63:boss", + "id": "Sboss>-82>>S-69:all", + "user": "boss", "group": "-69:all" } ``` @@ -883,7 +884,7 @@ access_permission: ##### Method & Url ``` -POST http://localhost:8080/graphs/hugegraph/auth/accesses +POST http://localhost:8080/graphspaces/DEFAULT/auth/accesses ``` ##### Response Status @@ -916,7 +917,7 @@ POST http://localhost:8080/graphs/hugegraph/auth/accesses ##### Method & Url ``` -DELETE http://localhost:8080/graphs/hugegraph/auth/accesses/S-69:all>-88>12>S-77:all +DELETE http://localhost:8080/graphspaces/DEFAULT/auth/accesses/S-69:all>-88>12>S-77:all ``` ##### Response Status @@ -941,7 +942,7 @@ DELETE http://localhost:8080/graphs/hugegraph/auth/accesses/S-69:all>-88>12>S-77 ##### Method & Url ``` -PUT http://localhost:8080/graphs/hugegraph/auth/accesses/S-69:all>-88>12>S-77:all +PUT http://localhost:8080/graphspaces/DEFAULT/auth/accesses/S-69:all>-88>12>S-77:all ``` ##### Request Body @@ -982,7 +983,7 @@ PUT http://localhost:8080/graphs/hugegraph/auth/accesses/S-69:all>-88>12>S-77:al ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/auth/accesses +GET http://localhost:8080/graphspaces/DEFAULT/auth/accesses ``` ##### Response Status @@ -1018,7 +1019,7 @@ GET http://localhost:8080/graphs/hugegraph/auth/accesses ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/auth/accesses/S-69:all>-88>11>S-77:all +GET http://localhost:8080/graphspaces/DEFAULT/auth/accesses/S-69:all>-88>11>S-77:all ``` ##### Response Status @@ -1040,3 +1041,161 @@ GET http://localhost:8080/graphs/hugegraph/auth/accesses/S-69:all>-88>11>S-77:al "target": "-77:all" } ``` + +### 10.7 图空间管理员(Manager)API + +**重要提示**:在使用以下 API 之前,需要先创建图空间(graphspace)。请参考 [Graphspace API](../graphspace) 创建名为 `gs1` 的图空间。文档中的示例均假设已存在名为 `gs1` 的图空间 + +1. 图空间管理员 API 用于在 graphspace 维度给用户授予/回收管理员角色,并查询当前用户或其他用户在该 graphspace 下的角色信息。角色类型可取 `SPACE`、`SPACE_MEMBER`、`ADMIN` 。 + +#### 10.7.1 检查当前登录用户是否拥有某个角色 + +##### Params + +- type: 需要校验的角色类型,可选 + +##### Method & Url + +``` +GET http://localhost:8080/graphspaces/gs1/auth/managers/check?type=WRITE +``` + +##### Response Status + +```json +200 +``` + +##### Response Body + +```json +"true" +``` + +返回 `true/false` 字符串表示是否拥有对应角色。 + +#### 10.7.2 查询图空间管理员列表 + +##### Params + +- type: 角色类型,可选,按角色过滤 + +##### Method & Url + +``` +GET http://localhost:8080/graphspaces/gs1/auth/managers?type=SPACE +``` + +##### Response Status + +```json +200 +``` + +##### Response Body + +```json +{ + "managers": [ + { + "user": "admin", + "type": "SPACE", + "create_time": "2024-01-10 09:30:00" + } + ] +} +``` + +#### 10.7.3 授权/创建图空间管理员 + +- 下面在 gs1 下,将用户 boss 授权为 SPACE_MEMBER 角色 + +##### Request Body + +```json +{ + "user": "boss", + "type": "SPACE_MEMBER" +} +``` + +##### Method & Url + +``` +POST http://localhost:8080/graphspaces/gs1/auth/managers +``` + +##### Response Status + +```json +201 +``` + +##### Response Body + +```json +{ + "user": "boss", + "type": "SPACE_MEMBER", + "manager_creator": "admin", + "manager_create": "2024-01-10 09:45:12" +} +``` + +#### 10.7.4 取消图空间管理员权限 + +- 下面在 gs1 下,将用户 boss 的 SPACE_MEMBER 角色删除 + +##### Params + +- user: 需要删除的用户 Id +- type: 需要删除的角色类型 + +##### Method & Url + +``` +DELETE http://localhost:8080/graphspaces/gs1/auth/managers?user=boss&type=SPACE_MEMBER +``` + +##### Response Status + +```json +204 +``` + +##### Response Body + +```json +1 +``` + +#### 10.7.5 查询指定用户在图空间中的角色 + +##### Params + +- user: 用户 Id + +##### Method & Url + +``` +GET http://localhost:8080/graphspaces/gs1/auth/managers/role?user=boss +``` + +##### Response Status + +```json +200 +``` + +##### Response Body + +```json +{ + "roles": { + "boss": [ + "READ", + "SPACE_MEMBER" + ] + } +} +``` diff --git a/content/cn/docs/clients/restful-api/cypher.md b/content/cn/docs/clients/restful-api/cypher.md index b3efdf630..7eddf199c 100644 --- a/content/cn/docs/clients/restful-api/cypher.md +++ b/content/cn/docs/clients/restful-api/cypher.md @@ -6,23 +6,31 @@ weight: 15 ### 9.1 Cypher -#### 9.1.1 向HugeGraphServer发送Cypher语句(GET),同步执行 +#### 9.1.1 向 HugeGraphServer 发送 Cypher 语句(GET),同步执行 ##### Method & Url ```javascript -GET /graphs/{graph}/cypher?cypher={cypher} +GET /graphspaces/{graphspace}/graphs/{graph}/cypher?cypher={cypher} ``` ##### Params + +**路径参数说明:** + +- graphspace: 图空间名称 - graph: 图名称 -- cypher: cypher语句 + +**请求参数说明:** + +- cypher: cypher 语句 ##### 使用示例 ```javascript -GET http://localhost:8080/graphs/hugecypher1/cypher?cypher=match(n:person) return n.name as name order by n.name limit 1 +GET +http://localhost:8080/graphspaces/DEFAULT/graphs/hugecypher1/cypher?cypher=match(n:person) return n.name as name order by n.name limit 1 ``` ##### Response Status @@ -53,30 +61,36 @@ GET http://localhost:8080/graphs/hugecypher1/cypher?cypher=match(n:person) retur } ``` -#### 9.1.2 向HugeGraphServer发送Cypher语句(POST),同步执行 +#### 9.1.2 向 HugeGraphServer 发送 Cypher 语句(POST),同步执行 ##### Method & Url ```javascript -POST /graphs/{graph}/cypher +POST /graphspaces/{graphspace}/graphs/{graph}/cypher ``` ##### Params + +**路径参数说明:** + +- graphspace: 图空间名称 - graph: 图名称 ##### Body {cypher} -- cypher: cypher语句 + +- cypher: cypher 语句 注意: -> 不是JSON格式,是纯文本的Cypher语句 +> 不是 JSON 格式,是纯文本的 Cypher 语句 ##### 使用示例 ```javascript -POST http://localhost:8080/graphs/hugecypher1/cypher +POST +http://localhost:8080/graphspaces/DEFAULT/graphs/hugecypher1/cypher ``` ###### Request Body diff --git a/content/cn/docs/clients/restful-api/edge.md b/content/cn/docs/clients/restful-api/edge.md index e164a142b..d17242a2b 100644 --- a/content/cn/docs/clients/restful-api/edge.md +++ b/content/cn/docs/clients/restful-api/edge.md @@ -61,6 +61,7 @@ g = graph.traversal() **路径参数说明:** +- graphspace: 图空间名称 - graph:待操作的图 **请求体说明:** @@ -76,8 +77,8 @@ g = graph.traversal() ##### Method & Url -``` -POST http://localhost:8080/graphs/hugegraph/graph/edges +```bash +POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges ``` ##### Request Body @@ -126,6 +127,7 @@ POST http://localhost:8080/graphs/hugegraph/graph/edges **路径参数说明:** +- graphspace: 图空间名称 - graph:待操作的图 **请求参数说明:** @@ -138,8 +140,8 @@ POST http://localhost:8080/graphs/hugegraph/graph/edges ##### Method & Url -``` -POST http://localhost:8080/graphs/hugegraph/graph/edges/batch +```bash +POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges/batch ``` ##### Request Body @@ -192,6 +194,7 @@ POST http://localhost:8080/graphs/hugegraph/graph/edges/batch **路径参数说明:** +- graphspace: 图空间名称 - graph:待操作的图 - id:待操作的边 id @@ -205,8 +208,8 @@ POST http://localhost:8080/graphs/hugegraph/graph/edges/batch ##### Method & Url -``` -PUT http://localhost:8080/graphs/hugegraph/graph/edges/S1:marko>2>>S2:lop?action=append +```http +PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges/S1:marko>2>>S2:lop?action=append ``` ##### Request Body @@ -251,6 +254,7 @@ PUT http://localhost:8080/graphs/hugegraph/graph/edges/S1:marko>2>>S2:lop?action **路径参数说明:** +- graphspace: 图空间名称 - graph:待操作的图 **请求体说明:** @@ -267,8 +271,8 @@ PUT http://localhost:8080/graphs/hugegraph/graph/edges/S1:marko>2>>S2:lop?action ##### Method & Url -``` -PUT http://127.0.0.1:8080/graphs/hugegraph/graph/edges/batch +```http +PUT http://127.0.0.1:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges/batch ``` ##### Request Body @@ -355,6 +359,7 @@ PUT http://127.0.0.1:8080/graphs/hugegraph/graph/edges/batch **路径参数说明:** +- graphspace: 图空间名称 - graph:待操作的图 - id:待操作的边 id @@ -368,8 +373,8 @@ PUT http://127.0.0.1:8080/graphs/hugegraph/graph/edges/batch ##### Method & Url -``` -PUT http://localhost:8080/graphs/hugegraph/graph/edges/S1:marko>2>>S2:lop?action=eliminate +```http +PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges/S1:marko>2>>S2:lop?action=eliminate ``` ##### Request Body @@ -408,6 +413,7 @@ PUT http://localhost:8080/graphs/hugegraph/graph/edges/S1:marko>2>>S2:lop?action **路径参数说明:** +- graphspace: 图空间名称 - graph:待操作的图 **请求参数说明:** @@ -442,8 +448,8 @@ PUT http://localhost:8080/graphs/hugegraph/graph/edges/S1:marko>2>>S2:lop?action ##### Method & Url -``` -GET http://127.0.0.1:8080/graphs/hugegraph/graph/edges?vertex_id="1:marko"&label=knows&properties={"date":"P.within(\"20160111\")"} +```http +GET http://127.0.0.1:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges?vertex_id="1:marko"&label=knows&properties={"date":"P.within(\"20160111\")"} ``` ##### Response Status @@ -478,8 +484,8 @@ GET http://127.0.0.1:8080/graphs/hugegraph/graph/edges?vertex_id="1:marko"&label ##### Method & Url -``` -GET http://127.0.0.1:8080/graphs/hugegraph/graph/edges?page&limit=2 +```http +GET http://127.0.0.1:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges?page&limit=2 ``` ##### Response Status @@ -530,8 +536,8 @@ GET http://127.0.0.1:8080/graphs/hugegraph/graph/edges?page&limit=2 ##### Method & Url -``` -GET http://127.0.0.1:8080/graphs/hugegraph/graph/edges?page=EoYxOm1hcmtvgggCAIQyOmxvcAAAAAAAAAAC&limit=2 +```http +GET http://127.0.0.1:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges?page=EoYxOm1hcmtvgggCAIQyOmxvcAAAAAAAAAAC&limit=2 ``` ##### Response Status @@ -573,13 +579,14 @@ GET http://127.0.0.1:8080/graphs/hugegraph/graph/edges?page=EoYxOm1hcmtvgggCAIQy **路径参数说明:** +- graphspace: 图空间名称 - graph:待操作的图 - id:待操作的边 id ##### Method & Url -``` -GET http://localhost:8080/graphs/hugegraph/graph/edges/S1:marko>2>>S2:lop +```http +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges/S1:marko>2>>S2:lop ``` ##### Response Status @@ -612,6 +619,7 @@ GET http://localhost:8080/graphs/hugegraph/graph/edges/S1:marko>2>>S2:lop **路径参数说明:** +- graphspace: 图空间名称 - graph:待操作的图 - id:待操作的边 id @@ -623,8 +631,8 @@ GET http://localhost:8080/graphs/hugegraph/graph/edges/S1:marko>2>>S2:lop ##### Method & Url -``` -DELETE http://localhost:8080/graphs/hugegraph/graph/edges/S1:marko>2>>S2:lop +```http +DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges/S1:marko>2>>S2:lop ``` ##### Response Status @@ -639,8 +647,8 @@ DELETE http://localhost:8080/graphs/hugegraph/graph/edges/S1:marko>2>>S2:lop ##### Method & Url -``` -DELETE http://localhost:8080/graphs/hugegraph/graph/edges/S1:marko>1>>S1:vadas?label=knows +```http +DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges/S1:marko>1>>S1:vadas?label=knows ``` ##### Response Status diff --git a/content/cn/docs/clients/restful-api/edgelabel.md b/content/cn/docs/clients/restful-api/edgelabel.md index 5e767bfd1..145992c22 100644 --- a/content/cn/docs/clients/restful-api/edgelabel.md +++ b/content/cn/docs/clients/restful-api/edgelabel.md @@ -6,26 +6,25 @@ weight: 4 ### 1.4 EdgeLabel -假设已经创建好了1.2.3中的 PropertyKeys 和 1.3.3中的 VertexLabels +假设已经创建好了 1.2.3 中的 PropertyKeys 和 1.3.3 中的 VertexLabels -Params说明 +Params 说明 - name:顶点类型名称,必填 - source_label: 源顶点类型的名称,必填 - target_label: 目标顶点类型的名称,必填 -- frequency:两个点之间是否可以有多条边,可以取值SINGLE和MULTIPLE,非必填,默认值SINGLE +- frequency:两个点之间是否可以有多条边,可以取值 SINGLE 和 MULTIPLE,非必填,默认值 SINGLE - properties: 边类型关联的属性类型,选填 - sort_keys: 当允许关联多次时,指定区分键属性列表 - nullable_keys:可为空的属性,选填,默认可为空 -- enable_label_index: 是否开启类型索引,默认关闭 +- enable_label_index:是否开启类型索引,默认关闭 - -#### 1.4.1 创建一个EdgeLabel +#### 1.4.1 创建一个 EdgeLabel ##### Method & Url ``` -POST http://localhost:8080/graphs/hugegraph/schema/edgelabels +POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/edgelabels ``` ##### Request Body @@ -125,7 +124,7 @@ POST http://localhost:8080/graphs/hugegraph/schema/edgelabels } ``` -#### 1.4.2 为已存在的EdgeLabel添加properties或userdata,或者移除userdata(目前不支持移除properties) +#### 1.4.2 为已存在的 EdgeLabel 添加 properties 或 userdata,或者移除 userdata(目前不支持移除 properties) ##### Params @@ -134,7 +133,7 @@ POST http://localhost:8080/graphs/hugegraph/schema/edgelabels ##### Method & Url ``` -PUT http://localhost:8080/graphs/hugegraph/schema/edgelabels/created?action=append +PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/edgelabels/created?action=append ``` ##### Request Body @@ -182,12 +181,12 @@ PUT http://localhost:8080/graphs/hugegraph/schema/edgelabels/created?action=appe } ``` -#### 1.4.3 获取所有的EdgeLabel +#### 1.4.3 获取所有的 EdgeLabel ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/schema/edgelabels +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/edgelabels ``` ##### Response Status @@ -244,12 +243,12 @@ GET http://localhost:8080/graphs/hugegraph/schema/edgelabels } ``` -#### 1.4.4 根据name获取EdgeLabel +#### 1.4.4 根据 name 获取 EdgeLabel ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/schema/edgelabels/created +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/edgelabels/created ``` ##### Response Status @@ -285,14 +284,14 @@ GET http://localhost:8080/graphs/hugegraph/schema/edgelabels/created } ``` -#### 1.4.5 根据name删除EdgeLabel +#### 1.4.5 根据 name 删除 EdgeLabel 删除 EdgeLabel 会导致删除对应的边以及相关的索引数据,会产生一个异步任务 ##### Method & Url ``` -DELETE http://localhost:8080/graphs/hugegraph/schema/edgelabels/created +DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/edgelabels/created ``` ##### Response Status @@ -311,4 +310,4 @@ DELETE http://localhost:8080/graphs/hugegraph/schema/edgelabels/created 注: -> 可以通过`GET http://localhost:8080/graphs/hugegraph/tasks/1`(其中"1"是task_id)来查询异步任务的执行状态,更多[异步任务RESTful API](../task) \ No newline at end of file +> 可以通过`GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/1`(其中"1"是 task_id)来查询异步任务的执行状态,更多[异步任务 RESTful API](../task) diff --git a/content/cn/docs/clients/restful-api/graphs.md b/content/cn/docs/clients/restful-api/graphs.md index 9e1b8a8d7..5229a9432 100644 --- a/content/cn/docs/clients/restful-api/graphs.md +++ b/content/cn/docs/clients/restful-api/graphs.md @@ -6,12 +6,20 @@ weight: 12 ### 6.1 Graphs -#### 6.1.1 列出数据库中全部的图 +**重要提醒**:1.7.0 及之后,动态创建图必须开启鉴权模式。非鉴权模式请参考[图配置文件](https://hugegraph.apache.org/cn/docs/config/config-guide/#4-hugegraphproperties),通过配置文件静态创建图。 + +#### 6.1.1 列出图空间中全部的图 + +##### Params + +**路径参数说明:** + +- graphspace: 图空间名称 ##### Method & Url ``` -GET http://localhost:8080/graphs +GET http://localhost:8080/graphspaces/DEFAULT/graphs ``` ##### Response Status @@ -33,10 +41,17 @@ GET http://localhost:8080/graphs #### 6.1.2 查看某个图的信息 +##### Params + +**路径参数说明:** + +- graphspace: 图空间名称 +- graph: 图名称 + ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph ``` ##### Response Status @@ -58,6 +73,13 @@ GET http://localhost:8080/graphs/hugegraph ##### Params +**路径参数说明:** + +- graphspace: 图空间名称 +- graph: 图名称 + +**请求参数说明:** + 由于清空图是一个比较危险的操作,为避免用户误调用,我们给 API 添加了用于确认的参数: - confirm_message: 默认为`I'm sure to delete all data` @@ -65,7 +87,7 @@ GET http://localhost:8080/graphs/hugegraph ##### Method & Url ``` -DELETE http://localhost:8080/graphs/hugegraph/clear?confirm_message=I%27m+sure+to+delete+all+data +DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/clear?confirm_message=I%27m+sure+to+delete+all+data ``` ##### Response Status @@ -78,25 +100,34 @@ DELETE http://localhost:8080/graphs/hugegraph/clear?confirm_message=I%27m+sure+t ##### Params +**路径参数说明:** + +- graphspace: 图空间名称 +- graph: 要创建的新图名称 + +**请求参数说明:** + - clone_graph_name: 已有图的名称;从已有的图来克隆,用户可选择传递配置文件,传递时将替换已有图中的配置; ##### Method & Url ``` -POST http://localhost:8080/graphs/hugegraph_clone?clone_graph_name=hugegraph +POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph_clone?clone_graph_name=hugegraph ``` ##### Request Body (可选) -克隆 (fork) 一个无权限的新图 (body 类型必须设置为 `Context-Type=text/plain`) +克隆一个非鉴权模式的图(设置 `Content-Type: application/json`) -```properties -gremlin.graph=org.apache.hugegraph.HugeFactory -backend=rocksdb -serializer=binary -store=hugegraph_clone -rocksdb.data_path=./rks-data-xx -rocksdb.wal_path=./rks-data-xx +```json +{ + "gremlin.graph": "org.apache.hugegraph.HugeFactory", + "backend": "rocksdb", + "serializer": "binary", + "store": "hugegraph_clone", + "rocksdb.data_path": "./rks-data-xx", + "rocksdb.wal_path": "./rks-data-xx" +} ``` > Note: @@ -120,23 +151,32 @@ rocksdb.wal_path=./rks-data-xx #### 6.1.5 创建一个图,**该操作需要管理员权限** +##### Params + +**路径参数说明:** + +- graphspace: 图空间名称 +- graph: 图名称 + ##### Method & Url ``` -POST http://localhost:8080/graphs/hugegraph-xx +POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph-xx ``` ##### Request Body -新建一个无权限的新图 (body 类型必须设置为 `Context-Type=text/plain`) +创建一个非鉴权模式的图(设置 `Content-Type: application/json`) -```properties -gremlin.graph=org.apache.hugegraph.HugeFactory -backend=rocksdb -serializer=binary -store=hugegraph2 -rocksdb.data_path=./rks-data-xx -rocksdb.wal_path=./rks-data-xx +```json +{ + "gremlin.graph": "org.apache.hugegraph.HugeFactory", + "backend": "rocksdb", + "serializer": "binary", + "store": "hugegraph", + "rocksdb.data_path": "./rks-data-xx", + "rocksdb.wal_path": "./rks-data-xx" +} ``` > Note: @@ -153,7 +193,7 @@ rocksdb.wal_path=./rks-data-xx ```javascript { - "name": "hugegraph2", + "name":"hugegraph2", "backend": "rocksdb" } ``` @@ -162,6 +202,13 @@ rocksdb.wal_path=./rks-data-xx ##### Params +**路径参数说明:** + +- graphspace: 图空间名称 +- graph: 图名称 + +**请求参数说明:** + 由于删除图是一个比较危险的操作,为避免用户误调用,我们给 API 添加了用于确认的参数: - confirm_message: 默认为`I'm sure to drop the graph` @@ -169,7 +216,7 @@ rocksdb.wal_path=./rks-data-xx ##### Method & Url ```javascript -DELETE http://localhost:8080/graphs/hugegraph_clone?confirm_message=I%27m%20sure%20to%20drop%20the%20graph +DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph_clone?confirm_message=I%27m%20sure%20to%20drop%20the%20graph ``` ##### Response Status @@ -178,6 +225,8 @@ DELETE http://localhost:8080/graphs/hugegraph_clone?confirm_message=I%27m%20sure 204 ``` +> 注意:对于 HugeGraph 1.5.0 及之前版本,如需创建或删除图,请继续使用旧的 `text/plain`(properties)格式请求体,而不是 JSON。 + ### 6.2 Conf #### 6.2.1 查看某个图的配置,**该操作需要管理员权限** @@ -185,7 +234,8 @@ DELETE http://localhost:8080/graphs/hugegraph_clone?confirm_message=I%27m%20sure ##### Method & Url ```javascript -GET http://localhost:8080/graphs/hugegraph/conf +GET +http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/conf ``` ##### Response Status @@ -243,7 +293,7 @@ Restore 时存在两种不同的模式:Restoring 和 Merging ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/mode +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/mode ``` ##### Response Status @@ -267,7 +317,7 @@ GET http://localhost:8080/graphs/hugegraph/mode ##### Method & Url ``` -PUT http://localhost:8080/graphs/hugegraph/mode +PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/mode ``` ##### Request Body @@ -301,7 +351,7 @@ PUT http://localhost:8080/graphs/hugegraph/mode ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/graph_read_mode +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph_read_mode ``` ##### Response Status @@ -327,7 +377,7 @@ GET http://localhost:8080/graphs/hugegraph/graph_read_mode ##### Method & Url ``` -PUT http://localhost:8080/graphs/hugegraph/graph_read_mode +PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph_read_mode ``` ##### Request Body @@ -363,7 +413,7 @@ PUT http://localhost:8080/graphs/hugegraph/graph_read_mode ##### Method & Url ``` -PUT http://localhost:8080/graphs/hugegraph/snapshot_create +PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/snapshot_create ``` ##### Response Status @@ -389,7 +439,7 @@ PUT http://localhost:8080/graphs/hugegraph/snapshot_create ##### Method & Url ``` -PUT http://localhost:8080/graphs/hugegraph/snapshot_resume +PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/snapshot_resume ``` ##### Response Status @@ -417,7 +467,7 @@ PUT http://localhost:8080/graphs/hugegraph/snapshot_resume ##### Method & Url ``` -PUT http://localhost:8080/graphs/hugegraph/compact +PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/compact ``` ##### Response Status diff --git a/content/cn/docs/clients/restful-api/graphspace.md b/content/cn/docs/clients/restful-api/graphspace.md new file mode 100644 index 000000000..62231b3be --- /dev/null +++ b/content/cn/docs/clients/restful-api/graphspace.md @@ -0,0 +1,281 @@ +--- +title: "Graphspace API" +linkTitle: "Graphspace" +weight: 1 +description: "Graphspace(图空间)REST 接口:多租户与资源隔离的创建、查看、更新与删除,以及使用前置条件与限制。" +--- + +### 2.0 Graphspace + +在 HugeGraph 中,多租户是通过图空间(graph space)来实现的,资源的分配和隔离可以通过图空间进行。 + +**重要前置条件**: + +1. 目前图空间功能只支持在 hstore 模式下使用。 +2. 如果非 hstore 模式,则只能使用默认的图空间 `DEFAULT`,且不支持创建、删除和更新图空间的操作。 +3. 注意在 rest-server.properties 中,设置 `usePD=true`,并且 hugegraph.properties 中,设置 `backend=hstore` +4. 图空间功能必须开启鉴权模式,默认账密为 admin:pa,请务必修改默认密码,防止未授权访问。 + +#### 2.0.1 创建一个图空间 + +##### Method & Url + +``` +POST http://localhost:8080/graphspaces +``` + +##### Request Body + +注意:目前 cpu,内存,以及 k8s 相关功能暂未开放 + +| 名称 | 是否必填 | 类型 | 默认值 | 取值范围 | 说明 | +|------------------------------|------|---------|-------|-----------------------------------|-----------------------------------------------------------------------| +| name | 是 | String | | 小写字母、数字和下划线组成,首字符必须是小写字母,长度不超过 48 | 图空间的名字 | +| description | 是 | String | | | 图空间的描述信息 | +| cpu_limit | 是 | Int | | > 0 | CPU 核数 | +| memory_limit | 是 | Int | | > 0 | 内存大小,单位 GB | +| storage_limit | 是 | Int | | > 0 | 图空间的数据占据的磁盘空间上限 | +| compute_cpu_limit | 否 | Int | 0 | >= 0 | 针对图计算的额外资源配置,单位 cores。当该字段不配置或者配置为 0 时,会由 cpu_limit 字段的值进行覆盖 | +| compute_memory_limit | 否 | Int | 0 | >= 0 | 针对图计算的额外内存配置,单位 GB。当该字段不配置或者配置为 0 时,会由 memory_limit 字段的值进行覆盖 | +| oltp_namespace | 是 | String | | | OLTP 的 k8s 命名空间 | +| olap_namespace | 是 | String | | | OLAP 的 k8s 命名空间。当 olap_namespace 和 oltp_namespace 的值相同时,其配置的资源限额会进行合并 | +| storage_namespace | 是 | String | | | 存储的 k8s 命名空间 | +| operator_image_path | 否 | String | | | 图计算 operator 的镜像地址:在创建图空间时,允许指定对应的图计算镜像并交由 K8S 进行统一管理 | +| internal_algorithm_image_url | 否 | String | | | 图计算的算法镜像地址:在创建图空间时,允许指定图计算的算法镜像并交由 K8S 进行统一管理 | +| max_graph_number | 是 | Int | | > 0 | 图空间的图数目的上限 | +| max_role_number | 是 | Int | | > 0 | 图空间的角色数目的上限 | +| auth | 否 | Boolean | false | true, false | 图空间是否支持权限认证 | +| configs | 否 | Map | | | 其他配置信息 | + +```json +{ + "name": "gs1", + "description": "1st graph space", + "max_graph_number": 100, + "cpu_limit": 1000, + "memory_limit": 8192, + "storage_limit": 1000000, + "max_role_number": 10, + "auth": true, + "configs": {} +} +``` + +##### Response Status + +```json +201 +``` + +##### Response Body + +```json +{ + "name": "gs1", + "description": "1st graph space", + "cpu_limit": 1000, + "memory_limit": 8192, + "storage_limit": 1000000, + "compute_cpu_limit": 0, + "compute_memory_limit": 0, + "oltp_namespace": "hugegraph-server", + "olap_namespace": "hugegraph-server", + "storage_namespace": "hugegraph-server", + "operator_image_path": "127.0.0.1/hugegraph-registry/hugegraph-computer-operator:3.1.1", + "internal_algorithm_image_url": "127.0.0.1/hugegraph-registry/hugegraph-computer-algorithm:3.1.1", + "max_graph_number": 100, + "max_role_number": 10, + "cpu_used": 0, + "memory_used": 0, + "storage_used": 0, + "graph_number_used": 0, + "role_number_used": 0, + "auth": true +} +``` + +#### 2.0.2 列出系统所有图空间 + +##### Method & Url + +``` +GET http://localhost:8080/graphspaces +``` + +##### Response Status + +```json +200 +``` + +##### Response Body + +```json +{ + "graphSpaces": [ + "gs1", + "DEFAULT" + ] +} +``` + +#### 2.0.3 查看某个图空间 + +##### Params + +**路径参数说明:** + +- graphspace: 图空间名称 + +##### Method & Url + +``` +GET http://localhost:8080/graphspaces/gs1 +``` + +##### Response Status + +```json +200 +``` + +##### Response Body + +```json +{ + "name": "gs1", + "description": "1st graph space", + "cpu_limit": 1000, + "memory_limit": 8192, + "storage_limit": 1000000, + "oltp_namespace": "hugegraph-server", + "olap_namespace": "hugegraph-server", + "storage_namespace": "hugegraph-server", + "operator_image_path": "127.0.0.1/hugegraph-registry/hugegraph-computer-operator:3.1.1", + "internal_algorithm_image_url": "127.0.0.1/hugegraph-registry/hugegraph-computer-algorithm:3.1.1", + "compute_cpu_limit": 0, + "compute_memory_limit": 0, + "max_graph_number": 100, + "max_role_number": 10, + "cpu_used": 0, + "memory_used": 0, + "storage_used": 0, + "graph_number_used": 0, + "role_number_used": 0, + "auth": true +} +``` + +#### 2.0.4 更新某个图空间 + +> 注意:auth 鉴权配置,在创建图空间的过程一旦确定下来,不允许更新 + +##### Params + +**路径参数说明:** + +- graphspace: 图空间名称 + +**请求体说明:** + +- action: 标记本次操作为 Update 动作,取值固定为 "update" +- update: 即将更新的值,下述参数都应置于 update 中 + +| 名称 | 是否必填 | 类型 | 默认值 | 取值范围 | 说明 | +|------------------------------|------|--------|-----|------|-----------------------------------------------------------------------| +| name | 是 | String | | | 图空间名称 | +| description | 是 | String | | | 图空间的描述信息 | +| cpu_limit | 是 | Int | | > 0 | OLTP HugeGraphServer 的 CPU 核数 | +| memory_limit | 是 | Int | | > 0 | OLTP HugeGraphServer 的内存大小,单位 GB | +| storage_limit | 是 | Int | | > 0 | 图空间的数据占据的磁盘空间上限 | +| compute_cpu_limit | 否 | Int | 0 | >= 0 | 针对图计算的额外资源配置,单位 cores。当该字段不配置或者配置为 0 时,会由 cpu_limit 字段的值进行覆盖 | +| compute_memory_limit | 否 | Int | 0 | >= 0 | 针对图计算的额外内存配置,单位 GB。当该字段不配置或者配置为 0 时,会由 memory_limit 字段的值进行覆盖 | +| oltp_namespace | 是 | String | | | OLTP 的 k8s 命名空间 | +| olap_namespace | 是 | String | | | OLAP 的 k8s 命名空间。当 olap_namespace 和 oltp_namespace 的值相同时,其配置的资源限额会进行合并 | +| storage_namespace | 是 | String | | | 存储的 k8s 命名空间 | +| operator_image_path | 否 | String | | | 图计算 operator 的镜像地址:在更新图空间时,允许指定对应的图计算镜像并交由 K8S 进行统一管理 | +| internal_algorithm_image_url | 否 | String | | | 图计算的算法镜像地址:在更新图空间时,允许指定图计算的算法镜像并交由 K8S 进行统一管理 | +| max_graph_number | 是 | Int | | > 0 | 图空间的图数目的上限 | +| max_role_number | 是 | Int | | > 0 | 图空间的角色数目的上限 | + +##### Method & Url + +``` +PUT http://localhost:8080/graphspaces/gs1 +``` + +##### Request Body + +```json +{ + "action": "update", + "update": { + "name": "gs1", + "description": "1st graph space", + "cpu_limit": 2000, + "memory_limit": 40960, + "storage_limit": 2048, + "oltp_namespace": "hugegraph-server", + "olap_namespace": "hugegraph-server", + "operator_image_path": "127.0.0.1/hugegraph-registry/hugegraph-computer-operator:3.1.1", + "internal_algorithm_image_url": "127.0.0.1/hugegraph-registry/hugegraph-computer-algorithm:3.1.1", + "max_graph_number": 1000, + "max_role_number": 100 + } +} +``` + +##### Response Status + +```json +200 +``` + +##### Response Body + +```json +{ + "name": "gs1", + "description": "1st graph space", + "cpu_limit": 2000, + "memory_limit": 40960, + "storage_limit": 2048, + "oltp_namespace": "hugegraph-server", + "olap_namespace": "hugegraph-server", + "storage_namespace": "hugegraph-server", + "operator_image_path": "127.0.0.1/hugegraph-registry/hugegraph-computer-operator:3.1.1", + "internal_algorithm_image_url": "127.0.0.1/hugegraph-registry/hugegraph-computer-algorithm:3.1.1", + "compute_cpu_limit": 0, + "compute_memory_limit": 0, + "max_graph_number": 1000, + "max_role_number": 100, + "cpu_used": 0, + "memory_used": 0, + "storage_used": 0, + "graph_number_used": 0, + "role_number_used": 0, + "auth": true +} +``` + +#### 2.0.5 删除某个图空间 + +##### Params + +**路径参数说明:** + +- graphspace: 图空间名称 + +##### Method & Url + +``` +DELETE http://localhost:8080/graphspaces/gs1 +``` + +##### Response Status + +```json +204 +``` + +> 注意:删除图空间,会导致图空间的全部资源被释放。 diff --git a/content/cn/docs/clients/restful-api/gremlin.md b/content/cn/docs/clients/restful-api/gremlin.md index f72a2efc5..d2affc3ae 100644 --- a/content/cn/docs/clients/restful-api/gremlin.md +++ b/content/cn/docs/clients/restful-api/gremlin.md @@ -6,12 +6,12 @@ weight: 14 ### 8.1 Gremlin -#### 8.1.1 向HugeGraphServer发送gremlin语句(GET),同步执行 +#### 8.1.1 向 HugeGraphServer 发送 gremlin 语句(GET),同步执行 ##### Params - gremlin: 要发送给`HugeGraphServer`执行的`gremlin`语句 -- bindings: 用来绑定参数,key是字符串,value是绑定的值(只能是字符串或者数字),功能类似于MySQL的 Prepared Statement,用于加速语句执行 +- bindings: 用来绑定参数,key 是字符串,value 是绑定的值(只能是字符串或者数字),功能类似于 MySQL 的 Prepared Statement,用于加速语句执行 - language: 发送语句的语言类型,默认为`gremlin-groovy` - aliases: 为存在于图空间的已有变量添加别名 @@ -64,7 +64,7 @@ GET http://127.0.0.1:8080/gremlin?gremlin=hugegraph.traversal().V('1:marko') } ``` -#### 8.1.2 向HugeGraphServer发送gremlin语句(POST),同步执行 +#### 8.1.2 向 HugeGraphServer 发送 gremlin 语句(POST),同步执行 ##### Method & Url @@ -129,11 +129,11 @@ POST http://localhost:8080/gremlin 注意: > 这里是直接使用图对象(hugegraph),先获取其遍历器(traversal()),再获取顶点。 -不能直接写成`graph.traversal().V()`或`g.V()`,可以通过`"aliases": {"graph": "hugegraph", "g": "__g_hugegraph"}` -为图和遍历器添加别名后使用别名操作。其中,`hugegraph`是原生存在的变量,`__g_hugegraph`是`HugeGraphServer`额外添加的变量, -每个图都会存在一个对应的这样格式(__g_${graph})的遍历器对象。 +> 不能直接写成`graph.traversal().V()`或`g.V()`,可以通过`"aliases": {"graph": "hugegraph", "g": "__g_hugegraph"}` +> 为图和遍历器添加别名后使用别名操作。其中,`hugegraph`是原生存在的变量,`__g_hugegraph`是`HugeGraphServer`额外添加的变量, +> 每个图都会存在一个对应的这样格式(__g_${graph})的遍历器对象。 -> 响应体的结构与其他 Vertex 或 Edge 的 RESTful API的结构有区别,用户可能需要自行解析。 +> 响应体的结构与其他 Vertex 或 Edge 的 RESTful API 的结构有区别,用户可能需要自行解析。 **查询边** @@ -186,12 +186,12 @@ POST http://localhost:8080/gremlin } ``` -#### 8.1.3 向HugeGraphServer发送gremlin语句(POST),异步执行 +#### 8.1.3 向 HugeGraphServer 发送 gremlin 语句(POST),异步执行 ##### Method & Url ``` -POST http://localhost:8080/graphs/hugegraph/jobs/gremlin +POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/jobs/gremlin ``` **查询顶点** @@ -209,8 +209,8 @@ POST http://localhost:8080/graphs/hugegraph/jobs/gremlin 注意: -> 异步执行Gremlin语句暂不支持aliases,可以使用 `graph` 代表要操作的图,也可以直接使用图的名字, 例如 `hugegraph`; -另外`g`代表 traversal,等价于 `graph.traversal()` 或者 `hugegraph.traversal()` +> 异步执行 Gremlin 语句暂不支持 aliases,可以使用 `graph` 代表要操作的图,也可以直接使用图的名字,例如 `hugegraph`; +> 另外`g`代表 traversal,等价于 `graph.traversal()` 或者 `hugegraph.traversal()` ##### Response Status @@ -228,7 +228,7 @@ POST http://localhost:8080/graphs/hugegraph/jobs/gremlin 注: -> 可以通过`GET http://localhost:8080/graphs/hugegraph/tasks/1`(其中"1"是task_id)来查询异步任务的执行状态,更多[异步任务RESTful API](../task) +> 可以通过`GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/1`(其中"1"是 task_id)来查询异步任务的执行状态,更多[异步任务 RESTful API](../task) **查询边** @@ -259,4 +259,4 @@ POST http://localhost:8080/graphs/hugegraph/jobs/gremlin 注: -> 可以通过`GET http://localhost:8080/graphs/hugegraph/tasks/2`(其中"2"是task_id)来查询异步任务的执行状态,更多[异步任务RESTful API](../task) \ No newline at end of file +> 可以通过`GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/2`(其中"2"是 task_id)来查询异步任务的执行状态,更多[异步任务 RESTful API](../task) diff --git a/content/cn/docs/clients/restful-api/indexlabel.md b/content/cn/docs/clients/restful-api/indexlabel.md index 51904be52..efddfbbfb 100644 --- a/content/cn/docs/clients/restful-api/indexlabel.md +++ b/content/cn/docs/clients/restful-api/indexlabel.md @@ -6,14 +6,14 @@ weight: 5 ### 1.5 IndexLabel -假设已经创建好了1.1.3中的 PropertyKeys 、1.2.3中的 VertexLabels 以及 1.3.3中的 EdgeLabels +假设已经创建好了 1.1.3 中的 PropertyKeys、1.2.3 中的 VertexLabels 以及 1.3.3 中的 EdgeLabels -#### 1.5.1 创建一个IndexLabel +#### 1.5.1 创建一个 IndexLabel ##### Method & Url -``` -POST http://localhost:8080/graphs/hugegraph/schema/indexlabels +```bash +POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/indexlabels ``` ##### Request Body @@ -54,12 +54,12 @@ POST http://localhost:8080/graphs/hugegraph/schema/indexlabels } ``` -#### 1.5.2 获取所有的IndexLabel +#### 1.5.2 获取所有的 IndexLabel ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/schema/indexlabels +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/indexlabels ``` ##### Response Status @@ -118,12 +118,12 @@ GET http://localhost:8080/graphs/hugegraph/schema/indexlabels } ``` -#### 1.5.3 根据name获取IndexLabel +#### 1.5.3 根据 name 获取 IndexLabel ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/schema/indexlabels/personByCity +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/indexlabels/personByCity ``` ##### Response Status @@ -147,14 +147,14 @@ GET http://localhost:8080/graphs/hugegraph/schema/indexlabels/personByCity } ``` -#### 1.5.4 根据name删除IndexLabel +#### 1.5.4 根据 name 删除 IndexLabel 删除 IndexLabel 会导致删除相关的索引数据,会产生一个异步任务 ##### Method & Url ``` -DELETE http://localhost:8080/graphs/hugegraph/schema/indexlabels/personByCity +DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/indexlabels/personByCity ``` ##### Response Status @@ -173,4 +173,4 @@ DELETE http://localhost:8080/graphs/hugegraph/schema/indexlabels/personByCity 注: -> 可以通过`GET http://localhost:8080/graphs/hugegraph/tasks/1`(其中"1"是task_id)来查询异步任务的执行状态,更多[异步任务RESTful API](../task) \ No newline at end of file +> 可以通过`GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/1`(其中"1"是 task_id)来查询异步任务的执行状态,更多[异步任务 RESTful API](../task) diff --git a/content/cn/docs/clients/restful-api/propertykey.md b/content/cn/docs/clients/restful-api/propertykey.md index be17d5ec2..0f008f8b8 100644 --- a/content/cn/docs/clients/restful-api/propertykey.md +++ b/content/cn/docs/clients/restful-api/propertykey.md @@ -6,7 +6,7 @@ weight: 2 ### 1.2 PropertyKey -Params说明: +Params 说明: - name:属性类型名称,必填 - data_type:属性类型数据类型,包括:bool、byte、int、long、float、double、text、date、uuid、blob,默认 `text` 类型 (代表 string 字符串类型) @@ -14,17 +14,17 @@ Params说明: 请求体字段说明: -- id:属性类型id值 +- id:属性类型 id 值 - properties:属性的属性,对于属性而言,此项为空 -- user_data:设置属性类型的通用信息,比如可设置age属性的取值范围,最小为0,最大为100;目前此项不做任何校验,只为后期拓展提供预留入口 +- user_data:设置属性类型的通用信息,比如可设置 age 属性的取值范围,最小为 0,最大为 100;目前此项不做任何校验,只为后期拓展提供预留入口 #### 1.2.1 创建一个 PropertyKey ##### Method & Url -``` -POST http://localhost:8080/graphs/hugegraph/schema/propertykeys +```http request +POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/propertykeys ``` ##### Request Body @@ -72,8 +72,8 @@ POST http://localhost:8080/graphs/hugegraph/schema/propertykeys ##### Method & Url -``` -PUT http://localhost:8080/graphs/hugegraph/schema/propertykeys/age?action=append +```http request +PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/propertykeys/age?action=append ``` ##### Request Body @@ -122,7 +122,7 @@ PUT http://localhost:8080/graphs/hugegraph/schema/propertykeys/age?action=append ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/schema/propertykeys +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/propertykeys ``` ##### Response Status @@ -196,12 +196,12 @@ GET http://localhost:8080/graphs/hugegraph/schema/propertykeys } ``` -#### 1.2.4 根据name获取PropertyKey +#### 1.2.4 根据 name 获取 PropertyKey ##### Method & Url -``` -GET http://localhost:8080/graphs/hugegraph/schema/propertykeys/age +```http request +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/propertykeys/age ``` 其中,`age`为要获取的 PropertyKey 的名称 @@ -236,8 +236,8 @@ GET http://localhost:8080/graphs/hugegraph/schema/propertykeys/age ##### Method & Url -``` -DELETE http://localhost:8080/graphs/hugegraph/schema/propertykeys/age +```http request +DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/propertykeys/age ``` 其中,`age`为要删除的 PropertyKey 的名称 diff --git a/content/cn/docs/clients/restful-api/rank.md b/content/cn/docs/clients/restful-api/rank.md index 8ef45c7fa..780ed8298 100644 --- a/content/cn/docs/clients/restful-api/rank.md +++ b/content/cn/docs/clients/restful-api/rank.md @@ -13,16 +13,17 @@ HugeGraphServer 除了上一节提到的遍历(traverser)方法,还提供 #### 4.2.1 Personal Rank API -Personal Rank 算法典型场景是用于推荐应用中, 根据某个点现有的出边, 推荐具有相近 / 相同关系的其他点, -比如根据某个人的阅读记录 / 习惯, 向它推荐其他可能感兴趣的书, 或潜在的书友, 举例如下: -1. 假设给定 1个 Person 点 是 tom, 它喜欢 `a,b,c,d,e` 5本书, 我们的想给 tom 推荐一些书友, 以及一些书, 最容易的想法就是看看还有哪些人喜欢过这些书 (共同兴趣) -2. 那么此时, 需要有其它的 Person 点比如 neo, 他喜欢 `b,d,f` 3本书, 以及 jay, 它喜欢 `c,d,e,g` 4本书, lee 它喜欢 `a,d,e,f` 4本书 -3. 由于 tom 已经看过的书不需要重复推荐, 所以返回结果里应该期望推荐有共同喜好的其他书友看过, 但 tom 没看过的书, 比如推荐 "f" 和 "g" 书, 且优先级 f > g -4. 此时再计算 tom 的个性化 rank 值, 就会返回排序后 TopN 推荐的 书友 + 书 的结果了 (如果只需要推荐的书, 选择 OTHER_LABEL 即可) +Personal Rank 算法典型场景是用于推荐应用中,根据某个点现有的出边,推荐具有相近 / 相同关系的其他点, +比如根据某个人的阅读记录 / 习惯,向它推荐其他可能感兴趣的书,或潜在的书友,举例如下: + +1. 假设给定 1 个 Person 点 是 tom, 它喜欢 `a,b,c,d,e` 5 本书,我们的想给 tom 推荐一些书友,以及一些书,最容易的想法就是看看还有哪些人喜欢过这些书 (共同兴趣) +2. 那么此时,需要有其它的 Person 点比如 neo, 他喜欢 `b,d,f` 3 本书,以及 jay, 它喜欢 `c,d,e,g` 4 本书,lee 它喜欢 `a,d,e,f` 4 本书 +3. 由于 tom 已经看过的书不需要重复推荐,所以返回结果里应该期望推荐有共同喜好的其他书友看过,但 tom 没看过的书,比如推荐 "f" 和 "g" 书,且优先级 f > g +4. 此时再计算 tom 的个性化 rank 值,就会返回排序后 TopN 推荐的 书友 + 书 的结果了 (如果只需要推荐的书,选择 OTHER_LABEL 即可) ##### 4.2.1.0 数据准备 -上面是一个简单的例子, 这里再提供一个公开的 1MB 测试数据集 [MovieLens](https://grouplens.org/datasets/movielens/) 为例, +上面是一个简单的例子,这里再提供一个公开的 1MB 测试数据集 [MovieLens](https://grouplens.org/datasets/movielens/) 为例, 用户需下载该数据集,然后使用 HugeGraph-Loader 导入到 HugeGraph 中,简单起见,数据中顶点 user 和 movie 的属性都忽略,仅使用 id 字段即可,边 rating 的具体评分值也忽略。loader 使用的元数据 文件和输入源映射文件内容如下: @@ -123,10 +124,10 @@ schema.edgeLabel("rating") 假设有一个用户和物品的二分图,基于随机游走的 PersonalRank 算法步骤如下: 1. 选定一个起点用户 u,其初始权重为 1.0,从 Vu 开始游走(有 alpha 的概率走到邻居点,1 - alpha 的概率停留); -2. 如果决定向外游走, 那么会选取某一个类型的出边, 例如 `rating` 来查找共同的打分人: +2. 如果决定向外游走,那么会选取某一个类型的出边,例如 `rating` 来查找共同的打分人: 1. 那就从当前节点的邻居节点中按照均匀分布随机选择一个,并且按照均匀分布划分权重值; 2. 给源顶点补偿权重 1 - alpha; - 3. 重复步骤2; + 3. 重复步骤 2; 3. 达到一定步数或达到精度后收敛,得到推荐列表。 ###### Params @@ -139,12 +140,12 @@ schema.edgeLabel("rating") - alpha:每轮迭代时从某个点往外走的概率,与 PageRank 算法中的 alpha 类似,取值区间为 (0, 1], 默认值 `0.85` - max_degree: 查询过程中,单个顶点遍历的最大邻接边数目,默认为 `10000` - max_depth: 迭代次数,取值区间为 [2, 50], 默认值 `5` -- with_label:筛选结果中保留哪些结果,可选以下三类, 默认为 `BOTH_LABEL` +- with_label:筛选结果中保留哪些结果,可选以下三类,默认为 `BOTH_LABEL` - SAME_LABEL:仅保留与源顶点相同类别的顶点 - OTHER_LABEL:仅保留与源顶点不同类别(二分图的另一端)的顶点 - BOTH_LABEL:同时保留与源顶点相同和相反类别的顶点 - limit: 返回的顶点的最大数目,默认为 `100` -- max_diff: 提前收敛的精度差, 默认为 `0.0001` (*后续实现*) +- max_diff: 提前收敛的精度差,默认为 `0.0001` (*后续实现*) - sorted:返回的结果是否根据 rank 排序,为 true 时降序排列,反之不排序,默认为 `true` ##### 4.2.1.2 使用方法 @@ -152,7 +153,7 @@ schema.edgeLabel("rating") ###### Method & Url ``` -POST http://localhost:8080/graphs/hugegraph/traversers/personalrank +POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/traversers/personalrank ``` ###### Request Body @@ -298,16 +299,16 @@ public class Loader { - steps: 表示从起始顶点走过的路径规则,是一组 Step 的列表,每个 Step 对应结果中的一层,必填项。每个 Step 的结构如下: - direction:表示边的方向(OUT, IN, BOTH),默认是 BOTH - labels:边的类型列表,多个边类型取并集 - - max_degree:查询过程中,单个顶点遍历的最大邻接边数目,默认为 10000 (注: 0.12版之前 step 内仅支持 degree 作为参数名, 0.12开始统一使用 max_degree, 并向下兼容 degree 写法) + - max_degree:查询过程中,单个顶点遍历的最大邻接边数目,默认为 10000 (注:0.12 版之前 step 内仅支持 degree 作为参数名,0.12 开始统一使用 max_degree, 并向下兼容 degree 写法) - top:在结果中每一层只保留权重最高的前 N 个结果,默认为 100,最大值为 1000 -- capacity: 遍历过程中最大的访问的顶点数目,选填项,默认为10000000 +- capacity: 遍历过程中最大的访问的顶点数目,选填项,默认为 10000000 ##### 4.2.2.2 使用方法 ###### Method & Url ``` -POST http://localhost:8080/graphs/hugegraph/traversers/neighborrank +POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/traversers/neighborrank ``` ###### Request Body diff --git a/content/cn/docs/clients/restful-api/rebuild.md b/content/cn/docs/clients/restful-api/rebuild.md index eae5d175a..18e037448 100644 --- a/content/cn/docs/clients/restful-api/rebuild.md +++ b/content/cn/docs/clients/restful-api/rebuild.md @@ -6,12 +6,12 @@ weight: 6 ### 1.6 Rebuild -#### 1.6.1 重建IndexLabel +#### 1.6.1 重建 IndexLabel ##### Method & Url ``` -PUT http://localhost:8080/graphs/hugegraph/jobs/rebuild/indexlabels/personByCity +PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/jobs/rebuild/indexlabels/personByCity ``` ##### Response Status @@ -30,14 +30,14 @@ PUT http://localhost:8080/graphs/hugegraph/jobs/rebuild/indexlabels/personByCity 注: -> 可以通过`GET http://localhost:8080/graphs/hugegraph/tasks/1`(其中"1"是task_id)来查询异步任务的执行状态,更多[异步任务RESTful API](../task) +> 可以通过`GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/1`(其中"1"是 task_id)来查询异步任务的执行状态,更多[异步任务 RESTful API](../task) -#### 1.6.2 VertexLabel对应的全部索引重建 +#### 1.6.2 VertexLabel 对应的全部索引重建 ##### Method & Url -``` -PUT http://localhost:8080/graphs/hugegraph/jobs/rebuild/vertexlabels/person +```http request +PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/jobs/rebuild/vertexlabels/person ``` ##### Response Status @@ -56,14 +56,14 @@ PUT http://localhost:8080/graphs/hugegraph/jobs/rebuild/vertexlabels/person 注: -> 可以通过`GET http://localhost:8080/graphs/hugegraph/tasks/2`(其中"2"是task_id)来查询异步任务的执行状态,更多[异步任务RESTful API](../task) +> 可以通过`GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/2`(其中"2"是 task_id)来查询异步任务的执行状态,更多[异步任务 RESTful API](../task) -#### 1.6.3 EdgeLabel对应的全部索引重建 +#### 1.6.3 EdgeLabel 对应的全部索引重建 ##### Method & Url -``` -PUT http://localhost:8080/graphs/hugegraph/jobs/rebuild/edgelabels/created +```http request +PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/jobs/rebuild/edgelabels/created ``` ##### Response Status @@ -82,4 +82,4 @@ PUT http://localhost:8080/graphs/hugegraph/jobs/rebuild/edgelabels/created 注: -> 可以通过`GET http://localhost:8080/graphs/hugegraph/tasks/3`(其中"3"是task_id)来查询异步任务的执行状态,更多[异步任务RESTful API](../task) \ No newline at end of file +> 可以通过`GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/3`(其中"3"是 task_id)来查询异步任务的执行状态,更多[异步任务 RESTful API](../task) diff --git a/content/cn/docs/clients/restful-api/schema.md b/content/cn/docs/clients/restful-api/schema.md index 91cdd329a..f0e525b05 100644 --- a/content/cn/docs/clients/restful-api/schema.md +++ b/content/cn/docs/clients/restful-api/schema.md @@ -11,9 +11,9 @@ HugeGraph 提供单一接口获取某个图的全部 Schema 信息,包括:Pr ##### Method & Url ``` -GET http://localhost:8080/graphs/{graph_name}/schema +GET http://localhost:8080/graphspaces/DEFAULT/graphs/{graph_name}/schema -e.g: GET http://localhost:8080/graphs/hugegraph/schema +e.g: GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema ``` ##### Response Status @@ -319,4 +319,4 @@ e.g: GET http://localhost:8080/graphs/hugegraph/schema } ] } -``` \ No newline at end of file +``` diff --git a/content/cn/docs/clients/restful-api/task.md b/content/cn/docs/clients/restful-api/task.md index 584730e35..b91a5c5a3 100644 --- a/content/cn/docs/clients/restful-api/task.md +++ b/content/cn/docs/clients/restful-api/task.md @@ -16,7 +16,7 @@ weight: 13 ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/tasks?status=success +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks?status=success ``` ##### Response Status @@ -50,7 +50,7 @@ GET http://localhost:8080/graphs/hugegraph/tasks?status=success ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/tasks/2 +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/2 ``` ##### Response Status @@ -82,7 +82,7 @@ GET http://localhost:8080/graphs/hugegraph/tasks/2 ##### Method & Url ``` -DELETE http://localhost:8080/graphs/hugegraph/tasks/2 +DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/2 ``` ##### Response Status @@ -110,7 +110,7 @@ DELETE http://localhost:8080/graphs/hugegraph/tasks/2 ##### Method & Url ``` -PUT http://localhost:8080/graphs/hugegraph/tasks/2?action=cancel +PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/2?action=cancel ``` > 请保证在 10 秒内发送该请求,如果超过 10 秒发送,任务可能已经执行完成,无法取消。 diff --git a/content/cn/docs/clients/restful-api/traverser.md b/content/cn/docs/clients/restful-api/traverser.md index 12d7cd3bb..e246ede58 100644 --- a/content/cn/docs/clients/restful-api/traverser.md +++ b/content/cn/docs/clients/restful-api/traverser.md @@ -4,36 +4,36 @@ linkTitle: "Traverser" weight: 9 --- -### 3.1 traverser API概述 +### 3.1 traverser API 概述 -HugeGraphServer为HugeGraph图数据库提供了RESTful API接口。除了顶点和边的CRUD基本操作以外,还提供了一些遍历(traverser)方法,我们称为`traverser API`。这些遍历方法实现了一些复杂的图算法,方便用户对图进行分析和挖掘。 +HugeGraphServer 为 HugeGraph 图数据库提供了 RESTful API 接口。除了顶点和边的 CRUD 基本操作以外,还提供了一些遍历(traverser)方法,我们称为`traverser API`。这些遍历方法实现了一些复杂的图算法,方便用户对图进行分析和挖掘。 -HugeGraph支持的Traverser API包括: +HugeGraph 支持的 Traverser API 包括: -- K-out API,根据起始顶点,查找恰好N步可达的邻居,分为基础版和高级版: - - 基础版使用GET方法,根据起始顶点,查找恰好N步可达的邻居 - - 高级版使用POST方法,根据起始顶点,查找恰好N步可达的邻居,与基础版的不同在于: +- K-out API,根据起始顶点,查找恰好 N 步可达的邻居,分为基础版和高级版: + - 基础版使用 GET 方法,根据起始顶点,查找恰好 N 步可达的邻居 + - 高级版使用 POST 方法,根据起始顶点,查找恰好 N 步可达的邻居,与基础版的不同在于: - 支持只统计邻居数量 - 支持顶点和边属性过滤 - 支持返回到达邻居的最短路径 -- K-neighbor API,根据起始顶点,查找N步以内可达的所有邻居,分为基础版和高级版: - - 基础版使用GET方法,根据起始顶点,查找N步以内可达的所有邻居 - - 高级版使用POST方法,根据起始顶点,查找N步以内可达的所有邻居,与基础版的不同在于: +- K-neighbor API,根据起始顶点,查找 N 步以内可达的所有邻居,分为基础版和高级版: + - 基础版使用 GET 方法,根据起始顶点,查找 N 步以内可达的所有邻居 + - 高级版使用 POST 方法,根据起始顶点,查找 N 步以内可达的所有邻居,与基础版的不同在于: - 支持只统计邻居数量 - 支持顶点和边属性过滤 - 支持返回到达邻居的最短路径 - Same Neighbors, 查询两个顶点的共同邻居 -- Jaccard Similarity API,计算jaccard相似度,包括两种: - - 一种是使用GET方法,计算两个顶点的邻居的相似度(交并比) - - 一种是使用POST方法,在全图中查找与起点的jaccard similarity最高的N个点 +- Jaccard Similarity API,计算 jaccard 相似度,包括两种: + - 一种是使用 GET 方法,计算两个顶点的邻居的相似度(交并比) + - 一种是使用 POST 方法,在全图中查找与起点的 jaccard similarity 最高的 N 个点 - Shortest Path API,查找两个顶点之间的最短路径 - All Shortest Paths,查找两个顶点间的全部最短路径 - Weighted Shortest Path,查找起点到目标点的带权最短路径 - Single Source Shortest Path,查找一个点到其他各个点的加权最短路径 - Multi Node Shortest Path,查找指定顶点集之间两两最短路径 - Paths API,查找两个顶点间的全部路径,分为基础版和高级版: - - 基础版使用GET方法,根据起点和终点,查找两个顶点间的全部路径 - - 高级版使用POST方法,根据一组起点和一组终点,查找两个集合间符合条件的全部路径 + - 基础版使用 GET 方法,根据起点和终点,查找两个顶点间的全部路径 + - 高级版使用 POST 方法,根据一组起点和一组终点,查找两个集合间符合条件的全部路径 - Customized Paths API,从一批顶点出发,按(一种)模式遍历经过的全部路径 - Template Path API,指定起点和终点以及起点和终点间路径信息,查找符合的路径 - Crosspoints API,查找两个顶点的交点(共同祖先或者共同子孙) @@ -42,19 +42,19 @@ HugeGraph支持的Traverser API包括: - Rays API,从起始顶点出发,可到达边界的路径(即无环路径) - Fusiform Similarity API,查找一个顶点的梭形相似点 - Vertices API - - 按ID批量查询顶点; + - 按 ID 批量查询顶点; - 获取顶点的分区; - 按分区查询顶点; - Edges API - - 按ID批量查询边; + - 按 ID 批量查询边; - 获取边的分区; - 按分区查询边; -### 3.2. traverser API详解 +### 3.2. traverser API 详解 -使用方法中的例子,都是基于TinkerPop官网给出的图: +使用方法中的例子,都是基于 TinkerPop 官网给出的图: -![tinkerpop示例图](http://tinkerpop.apache.org/docs/3.4.0/images/tinkerpop-modern.png) +![tinkerpop 示例图](http://tinkerpop.apache.org/docs/3.4.0/images/tinkerpop-modern.png) 数据导入程序如下: @@ -168,7 +168,7 @@ public class Loader { } ``` -顶点ID为: +顶点 ID 为: ``` "2:ripple", @@ -179,7 +179,7 @@ public class Loader { "2:lop" ``` -边ID为: +边 ID 为: ``` "S1:peter>2>>S2:lop", @@ -194,25 +194,25 @@ public class Loader { ##### 3.2.1.1 功能介绍 -根据起始顶点、方向、边的类型(可选)和深度depth,查找从起始顶点出发恰好depth步可达的顶点 +根据起始顶点、方向、边的类型(可选)和深度 depth,查找从起始顶点出发恰好 depth 步可达的顶点 ###### Params -- source:起始顶点id,必填项 -- direction:起始顶点向外发散的方向(OUT,IN,BOTH),选填项,默认是BOTH +- source:起始顶点 id,必填项 +- direction:起始顶点向外发散的方向(OUT,IN,BOTH),选填项,默认是 BOTH - max_depth:步数,必填项 -- label:边的类型,选填项,默认代表所有edge label -- nearest:nearest为true时,代表起始顶点到达结果顶点的最短路径长度为depth,不存在更短的路径;nearest为false时,代表起始顶点到结果顶点有一条长度为depth的路径(未必最短且可以有环),选填项,默认为true -- max_degree:查询过程中,单个顶点遍历的最大邻接边数目,选填项,默认为10000 -- capacity:遍历过程中最大的访问的顶点数目,选填项,默认为10000000 -- limit:返回的顶点的最大数目,选填项,默认为10000000 +- label:边的类型,选填项,默认代表所有 edge label +- nearest:nearest 为 true 时,代表起始顶点到达结果顶点的最短路径长度为 depth,不存在更短的路径;nearest 为 false 时,代表起始顶点到结果顶点有一条长度为 depth 的路径(未必最短且可以有环),选填项,默认为 true +- max_degree:查询过程中,单个顶点遍历的最大邻接边数目,选填项,默认为 10000 +- capacity:遍历过程中最大的访问的顶点数目,选填项,默认为 10000000 +- limit:返回的顶点的最大数目,选填项,默认为 10000000 ##### 3.2.1.2 使用方法 ###### Method & Url ``` -GET http://localhost:8080/graphs/{graph}/traversers/kout?source="1:marko"&max_depth=2 +GET http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/kout?source="1:marko"&max_depth=2 ``` ###### Response Status @@ -234,51 +234,51 @@ GET http://localhost:8080/graphs/{graph}/traversers/kout?source="1:marko"&max_de ##### 3.2.1.3 适用场景 -查找恰好N步关系可达的顶点。两个例子: +查找恰好 N 步关系可达的顶点。两个例子: -- 家族关系中,查找一个人的所有孙子,person A通过连续的两条“儿子”边到达的顶点集合。 +- 家族关系中,查找一个人的所有孙子,person A 通过连续的两条“儿子”边到达的顶点集合。 - 社交关系中发现潜在好友,例如:与目标用户相隔两层朋友关系的用户,可以通过连续两条“朋友”边到达的顶点。 #### 3.2.2 K-out API(POST,高级版) ##### 3.2.2.1 功能介绍 -根据起始顶点、步骤(包括方向、边类型和过滤属性)和深度depth,查找从起始顶点出发恰好depth步可达的顶点。 +根据起始顶点、步骤(包括方向、边类型和过滤属性)和深度 depth,查找从起始顶点出发恰好 depth 步可达的顶点。 -> 与K-out基础版的不同在于: +> 与 K-out 基础版的不同在于: > - 支持只统计邻居数量 > - 支持边属性过滤 > - 支持返回到达邻居的最短路径 ###### Params -- source:起始顶点id,必填项 -- steps: 从起始点出发的Steps,必填项,结构如下: - - direction:表示边的方向(OUT,IN,BOTH),默认是BOTH - - edge_steps:边Step集合,支持对单边的类型和属性过滤,如果为空,则不过滤 +- source:起始顶点 id,必填项 +- steps: 从起始点出发的 Steps,必填项,结构如下: + - direction:表示边的方向(OUT,IN,BOTH),默认是 BOTH + - edge_steps:边 Step 集合,支持对单边的类型和属性过滤,如果为空,则不过滤 - label:边类型 - properties:边属性 - - vertex_steps:顶点Step集合,支持对单点的类型和属性过滤,如果为空,则不过滤 + - vertex_steps:顶点 Step 集合,支持对单点的类型和属性过滤,如果为空,则不过滤 - label:顶点类型 - properties:顶点属性 - - max_degree:查询过程中,单个顶点遍历的最大邻接边数目,默认为 10000 (注: 0.12版之前 step 内仅支持 degree 作为参数名, 0.12开始统一使用 max_degree, 并向下兼容 degree 写法) - - skip_degree:用于设置查询过程中舍弃超级顶点的最小边数,即当某个顶点的邻接边数目大于 skip_degree 时,完全舍弃该顶点。选填项,如果开启时,需满足 `skip_degree >= max_degree` 约束,默认为0 (不启用),表示不跳过任何点 (注意: 开启此配置后,遍历时会尝试访问一个顶点的 skip_degree 条边,而不仅仅是 max_degree 条边,这样有额外的遍历开销,对查询性能影响可能有较大影响,请确认理解后再开启) + - max_degree:查询过程中,单个顶点遍历的最大邻接边数目,默认为 10000 (注:0.12 版之前 step 内仅支持 degree 作为参数名,0.12 开始统一使用 max_degree, 并向下兼容 degree 写法) + - skip_degree:用于设置查询过程中舍弃超级顶点的最小边数,即当某个顶点的邻接边数目大于 skip_degree 时,完全舍弃该顶点。选填项,如果开启时,需满足 `skip_degree >= max_degree` 约束,默认为 0 (不启用),表示不跳过任何点 (注意:开启此配置后,遍历时会尝试访问一个顶点的 skip_degree 条边,而不仅仅是 max_degree 条边,这样有额外的遍历开销,对查询性能影响可能有较大影响,请确认理解后再开启) - max_depth:步数,必填项 -- nearest:nearest为true时,代表起始顶点到达结果顶点的最短路径长度为depth,不存在更短的路径;nearest为false时,代表起始顶点到结果顶点有一条长度为depth的路径(未必最短且可以有环),选填项,默认为true -- count_only:Boolean值,true表示只统计结果的数目,不返回具体结果;false表示返回具体的结果,默认为false -- with_path:true表示返回起始点到每个邻居的最短路径,false表示不返回起始点到每个邻居的最短路径,选填项,默认为false -- with_edge,选填项,默认为false: - - 如果设置为true,则结果将包含所有边的完整信息,即路径中的所有边 - - 当with_path为true时,将返回所有路径中的边的完整信息 - - 当with_path为false时,不返回任何信息 - - 如果设置为false,则仅返回边的id -- with_vertex,选填项,默认为false: - - 如果设置为true,则结果将包含所有顶点的完整信息,即路径中的所有顶点 - - 当with_path为true时,将返回所有路径中的顶点的完整信息 - - 当with_path为false时,返回所有邻居顶点的完整信息 - - 如果设置为false,则仅返回顶点的id -- capacity:遍历过程中最大的访问的顶点数目,选填项,默认为10000000 -- limit:返回的顶点的最大数目,选填项,默认为10000000 +- nearest:nearest 为 true 时,代表起始顶点到达结果顶点的最短路径长度为 depth,不存在更短的路径;nearest 为 false 时,代表起始顶点到结果顶点有一条长度为 depth 的路径(未必最短且可以有环),选填项,默认为 true +- count_only:Boolean 值,true 表示只统计结果的数目,不返回具体结果;false 表示返回具体的结果,默认为 false +- with_path:true 表示返回起始点到每个邻居的最短路径,false 表示不返回起始点到每个邻居的最短路径,选填项,默认为 false +- with_edge,选填项,默认为 false: + - 如果设置为 true,则结果将包含所有边的完整信息,即路径中的所有边 + - 当 with_path 为 true 时,将返回所有路径中的边的完整信息 + - 当 with_path 为 false 时,不返回任何信息 + - 如果设置为 false,则仅返回边的 id +- with_vertex,选填项,默认为 false: + - 如果设置为 true,则结果将包含所有顶点的完整信息,即路径中的所有顶点 + - 当 with_path 为 true 时,将返回所有路径中的顶点的完整信息 + - 当 with_path 为 false 时,返回所有邻居顶点的完整信息 + - 如果设置为 false,则仅返回顶点的 id +- capacity:遍历过程中最大的访问的顶点数目,选填项,默认为 10000000 +- limit:返回的顶点的最大数目,选填项,默认为 10000000 - traverse_mode: 遍历方式,可选择“breadth_first_search”或“depth_first_search”作为参数,默认为“breadth_first_search” ##### 3.2.2.2 使用方法 @@ -286,7 +286,7 @@ GET http://localhost:8080/graphs/{graph}/traversers/kout?source="1:marko"&max_de ###### Method & Url ``` -POST http://localhost:8080/graphs/{graph}/traversers/kout +POST http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/kout ``` ###### Request Body @@ -429,31 +429,31 @@ POST http://localhost:8080/graphs/{graph}/traversers/kout ##### 3.2.2.3 适用场景 -参见3.2.1.3 +参见 3.2.1.3 #### 3.2.3 K-neighbor(GET,基础版) ##### 3.2.3.1 功能介绍 -根据起始顶点、方向、边的类型(可选)和深度depth,查找包括起始顶点在内、depth步之内可达的所有顶点 +根据起始顶点、方向、边的类型(可选)和深度 depth,查找包括起始顶点在内、depth 步之内可达的所有顶点 -> 相当于:起始顶点、K-out(1)、K-out(2)、... 、K-out(max_depth)的并集 +> 相当于:起始顶点、K-out(1)、K-out(2)、... 、K-out(max_depth) 的并集 ###### Params -- source: 起始顶点id,必填项 -- direction:起始顶点向外发散的方向(OUT,IN,BOTH),选填项,默认是BOTH +- source: 起始顶点 id,必填项 +- direction:起始顶点向外发散的方向(OUT,IN,BOTH),选填项,默认是 BOTH - max_depth:步数,必填项 -- label:边的类型,选填项,默认代表所有edge label -- max_degree:查询过程中,单个顶点遍历的最大邻接边数目,选填项,默认为10000 -- limit:返回的顶点的最大数目,也即遍历过程中最大的访问的顶点数目,选填项,默认为10000000 +- label:边的类型,选填项,默认代表所有 edge label +- max_degree:查询过程中,单个顶点遍历的最大邻接边数目,选填项,默认为 10000 +- limit:返回的顶点的最大数目,也即遍历过程中最大的访问的顶点数目,选填项,默认为 10000000 ##### 3.2.3.2 使用方法 ###### Method & Url ``` -GET http://localhost:8080/graphs/{graph}/traversers/kneighbor?source=“1:marko”&max_depth=2 +GET http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/kneighbor?source=“1:marko”&max_depth=2 ``` ###### Response Status @@ -479,59 +479,59 @@ GET http://localhost:8080/graphs/{graph}/traversers/kneighbor?source=“1:marko ##### 3.2.3.3 适用场景 -查找N步以内可达的所有顶点,例如: +查找 N 步以内可达的所有顶点,例如: -- 家族关系中,查找一个人五服以内所有子孙,person A通过连续的5条“亲子”边到达的顶点集合。 -- 社交关系中发现好友圈子,例如目标用户通过1条、2条、3条“朋友”边可到达的用户可以组成目标用户的朋友圈子 +- 家族关系中,查找一个人五服以内所有子孙,person A 通过连续的 5 条“亲子”边到达的顶点集合。 +- 社交关系中发现好友圈子,例如目标用户通过 1 条、2 条、3 条“朋友”边可到达的用户可以组成目标用户的朋友圈子 #### 3.2.4 K-neighbor API(POST,高级版) ##### 3.2.4.1 功能介绍 -根据起始顶点、步骤(包括方向、边类型和过滤属性)和深度depth,查找从起始顶点出发depth步内可达的所有顶点。 +根据起始顶点、步骤(包括方向、边类型和过滤属性)和深度 depth,查找从起始顶点出发 depth 步内可达的所有顶点。 -> 与K-neighbor基础版的不同在于: +> 与 K-neighbor 基础版的不同在于: > - 支持只统计邻居数量 > - 支持边属性过滤 > - 支持返回到达邻居的最短路径 ###### Params -- source:起始顶点id,必填项 -- steps: 从起始点出发的Steps,必填项,结构如下: - - direction:表示边的方向(OUT,IN,BOTH),默认是BOTH - - 从起始点出发的Steps,必填项,结构如下: - - direction:表示边的方向(OUT,IN,BOTH),默认是BOTH - - edge_steps:边Step集合,支持对单边的类型和属性过滤,如果为空,则不过滤 +- source:起始顶点 id,必填项 +- steps: 从起始点出发的 Steps,必填项,结构如下: + - direction:表示边的方向(OUT,IN,BOTH),默认是 BOTH + - 从起始点出发的 Steps,必填项,结构如下: + - direction:表示边的方向(OUT,IN,BOTH),默认是 BOTH + - edge_steps:边 Step 集合,支持对单边的类型和属性过滤,如果为空,则不过滤 - label:边类型 - properties:边属性 - - vertex_steps:顶点Step集合,支持对单点的类型和属性过滤,如果为空,则不过滤 + - vertex_steps:顶点 Step 集合,支持对单点的类型和属性过滤,如果为空,则不过滤 - label:顶点类型 - properties:顶点属性 - - max_degree:查询过程中,单个顶点遍历的最大邻接边数目,默认为 10000 (注: 0.12版之前 step 内仅支持 degree 作为参数名, 0.12开始统一使用 max_degree, 并向下兼容 degree 写法) - - skip_degree:用于设置查询过程中舍弃超级顶点的最小边数,即当某个顶点的邻接边数目大于 skip_degree 时,完全舍弃该顶点。选填项,如果开启时,需满足 `skip_degree >= max_degree` 约束,默认为0 (不启用),表示不跳过任何点 (注意: 开启此配置后,遍历时会尝试访问一个顶点的 skip_degree 条边,而不仅仅是 max_degree 条边,这样有额外的遍历开销,对查询性能影响可能有较大影响,请确认理解后再开启) + - max_degree:查询过程中,单个顶点遍历的最大邻接边数目,默认为 10000 (注:0.12 版之前 step 内仅支持 degree 作为参数名,0.12 开始统一使用 max_degree, 并向下兼容 degree 写法) + - skip_degree:用于设置查询过程中舍弃超级顶点的最小边数,即当某个顶点的邻接边数目大于 skip_degree 时,完全舍弃该顶点。选填项,如果开启时,需满足 `skip_degree >= max_degree` 约束,默认为 0 (不启用),表示不跳过任何点 (注意:开启此配置后,遍历时会尝试访问一个顶点的 skip_degree 条边,而不仅仅是 max_degree 条边,这样有额外的遍历开销,对查询性能影响可能有较大影响,请确认理解后再开启) - max_depth:步数,必填项 -- count_only:Boolean值,true表示只统计结果的数目,不返回具体结果;false表示返回具体的结果,默认为false -- with_path:true表示返回起始点到每个邻居的最短路径,false表示不返回起始点到每个邻居的最短路径,选填项,默认为false -- with_edge,选填项,默认为false: - - 如果设置为true,则结果将包含所有边的完整信息,即路径中的所有边 - - 当with_path为true时,将返回所有路径中的边的完整信息 - - 当with_path为false时,不返回任何信息 - - 如果设置为false,则仅返回边的id -- with_vertex,选填项,默认为false: - - 如果设置为true,则结果将包含所有顶点的完整信息,即路径中的所有顶点 - - 当with_path为true时,将返回所有路径中的顶点的完整信息 - - 当with_path为false时,返回所有邻居顶点的完整信息 - - 如果设置为false,则仅返回顶点的id -- limit:返回的顶点的最大数目,选填项,默认为10000000 +- count_only:Boolean 值,true 表示只统计结果的数目,不返回具体结果;false 表示返回具体的结果,默认为 false +- with_path:true 表示返回起始点到每个邻居的最短路径,false 表示不返回起始点到每个邻居的最短路径,选填项,默认为 false +- with_edge,选填项,默认为 false: + - 如果设置为 true,则结果将包含所有边的完整信息,即路径中的所有边 + - 当 with_path 为 true 时,将返回所有路径中的边的完整信息 + - 当 with_path 为 false 时,不返回任何信息 + - 如果设置为 false,则仅返回边的 id +- with_vertex,选填项,默认为 false: + - 如果设置为 true,则结果将包含所有顶点的完整信息,即路径中的所有顶点 + - 当 with_path 为 true 时,将返回所有路径中的顶点的完整信息 + - 当 with_path 为 false 时,返回所有邻居顶点的完整信息 + - 如果设置为 false,则仅返回顶点的 id +- limit:返回的顶点的最大数目,选填项,默认为 10000000 ##### 3.2.4.2 使用方法 ###### Method & Url ``` -POST http://localhost:8080/graphs/{graph}/traversers/kneighbor +POST http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/kneighbor ``` ###### Request Body @@ -730,7 +730,7 @@ POST http://localhost:8080/graphs/{graph}/traversers/kneighbor ##### 3.2.4.3 适用场景 -参见3.2.3.3 +参见 3.2.3.3 #### 3.2.5 Same Neighbors @@ -740,19 +740,19 @@ POST http://localhost:8080/graphs/{graph}/traversers/kneighbor ###### Params -- vertex:一个顶点id,必填项 -- other:另一个顶点id,必填项 -- direction:顶点向外发散的方向(OUT,IN,BOTH),选填项,默认是BOTH -- label:边的类型,选填项,默认代表所有edge label -- max_degree:查询过程中,单个顶点遍历的最大邻接边数目,选填项,默认为10000 -- limit:返回的共同邻居的最大数目,选填项,默认为10000000 +- vertex:一个顶点 id,必填项 +- other:另一个顶点 id,必填项 +- direction:顶点向外发散的方向(OUT,IN,BOTH),选填项,默认是 BOTH +- label:边的类型,选填项,默认代表所有 edge label +- max_degree:查询过程中,单个顶点遍历的最大邻接边数目,选填项,默认为 10000 +- limit:返回的共同邻居的最大数目,选填项,默认为 10000000 ##### 3.2.5.2 使用方法 ###### Method & Url ``` -GET http://localhost:8080/graphs/{graph}/traversers/sameneighbors?vertex=“1:marko”&other="1:josh" +GET http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/sameneighbors?vertex=“1:marko”&other="1:josh" ``` ###### Response Status @@ -777,26 +777,26 @@ GET http://localhost:8080/graphs/{graph}/traversers/sameneighbors?vertex=“1:ma - 社交关系中发现两个用户的共同粉丝或者共同关注用户 -#### 3.2.6 Jaccard Similarity(GET) +#### 3.2.6 Jaccard Similarity (GET) ##### 3.2.6.1 功能介绍 -计算两个顶点的jaccard similarity(两个顶点邻居的交集比上两个顶点邻居的并集) +计算两个顶点的 jaccard similarity(两个顶点邻居的交集比上两个顶点邻居的并集) ###### Params -- vertex:一个顶点id,必填项 -- other:另一个顶点id,必填项 -- direction:顶点向外发散的方向(OUT,IN,BOTH),选填项,默认是BOTH -- label:边的类型,选填项,默认代表所有edge label -- max_degree:查询过程中,单个顶点遍历的最大邻接边数目,选填项,默认为10000 +- vertex:一个顶点 id,必填项 +- other:另一个顶点 id,必填项 +- direction:顶点向外发散的方向(OUT,IN,BOTH),选填项,默认是 BOTH +- label:边的类型,选填项,默认代表所有 edge label +- max_degree:查询过程中,单个顶点遍历的最大邻接边数目,选填项,默认为 10000 ##### 3.2.6.2 使用方法 ###### Method & Url ``` -GET http://localhost:8080/graphs/{graph}/traversers/jaccardsimilarity?vertex="1:marko"&other="1:josh" +GET http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/jaccardsimilarity?vertex="1:marko"&other="1:josh" ``` ###### Response Status @@ -817,32 +817,32 @@ GET http://localhost:8080/graphs/{graph}/traversers/jaccardsimilarity?vertex="1: 用于评估两个点的相似性或者紧密度 -#### 3.2.7 Jaccard Similarity(POST) +#### 3.2.7 Jaccard Similarity (POST) ##### 3.2.7.1 功能介绍 -计算与指定顶点的jaccard similarity最大的N个点 +计算与指定顶点的 jaccard similarity 最大的 N 个点 -> jaccard similarity的计算方式为:两个顶点邻居的交集比上两个顶点邻居的并集 +> jaccard similarity 的计算方式为:两个顶点邻居的交集比上两个顶点邻居的并集 ###### Params -- vertex:一个顶点id,必填项 -- 从起始点出发的Step,必填项,结构如下: - - direction:表示边的方向(OUT,IN,BOTH),默认是BOTH +- vertex:一个顶点 id,必填项 +- 从起始点出发的 Step,必填项,结构如下: + - direction:表示边的方向(OUT,IN,BOTH),默认是 BOTH - labels:边的类型列表 - properties:通过属性的值过滤边 - - max_degree:查询过程中,单个顶点遍历的最大邻接边数目,默认为 10000 (注: 0.12版之前 step 内仅支持 degree 作为参数名, 0.12开始统一使用 max_degree, 并向下兼容 degree 写法) - - skip_degree:用于设置查询过程中舍弃超级顶点的最小边数,即当某个顶点的邻接边数目大于 skip_degree 时,完全舍弃该顶点。选填项,如果开启时,需满足 `skip_degree >= max_degree` 约束,默认为0 (不启用),表示不跳过任何点 (注意: 开启此配置后,遍历时会尝试访问一个顶点的 skip_degree 条边,而不仅仅是 max_degree 条边,这样有额外的遍历开销,对查询性能影响可能有较大影响,请确认理解后再开启) -- top:返回一个起点的jaccard similarity中最大的top个,选填项,默认为100 -- capacity:遍历过程中最大的访问的顶点数目,选填项,默认为10000000 + - max_degree:查询过程中,单个顶点遍历的最大邻接边数目,默认为 10000 (注:0.12 版之前 step 内仅支持 degree 作为参数名,0.12 开始统一使用 max_degree, 并向下兼容 degree 写法) + - skip_degree:用于设置查询过程中舍弃超级顶点的最小边数,即当某个顶点的邻接边数目大于 skip_degree 时,完全舍弃该顶点。选填项,如果开启时,需满足 `skip_degree >= max_degree` 约束,默认为 0 (不启用),表示不跳过任何点 (注意:开启此配置后,遍历时会尝试访问一个顶点的 skip_degree 条边,而不仅仅是 max_degree 条边,这样有额外的遍历开销,对查询性能影响可能有较大影响,请确认理解后再开启) +- top:返回一个起点的 jaccard similarity 中最大的 top 个,选填项,默认为 100 +- capacity:遍历过程中最大的访问的顶点数目,选填项,默认为 10000000 ##### 3.2.7.2 使用方法 ###### Method & Url ``` -POST http://localhost:8080/graphs/{graph}/traversers/jaccardsimilarity +POST http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/jaccardsimilarity ``` ###### Request Body @@ -888,21 +888,21 @@ POST http://localhost:8080/graphs/{graph}/traversers/jaccardsimilarity ###### Params -- source:起始顶点id,必填项 -- target:目的顶点id,必填项 -- direction:起始顶点向外发散的方向(OUT,IN,BOTH),选填项,默认是BOTH +- source:起始顶点 id,必填项 +- target:目的顶点 id,必填项 +- direction:起始顶点向外发散的方向(OUT,IN,BOTH),选填项,默认是 BOTH - max_depth:最大步数,必填项 -- label:边的类型,选填项,默认代表所有edge label -- max_degree:查询过程中,单个顶点遍历的最大邻接边数目,选填项,默认为10000 -- skip_degree:用于设置查询过程中舍弃超级顶点的最小边数,即当某个顶点的邻接边数目大于 skip_degree 时,完全舍弃该顶点。选填项,如果开启时,需满足 `skip_degree >= max_degree` 约束,默认为0 (不启用),表示不跳过任何点 (注意: 开启此配置后,遍历时会尝试访问一个顶点的 skip_degree 条边,而不仅仅是 max_degree 条边,这样有额外的遍历开销,对查询性能影响可能有较大影响,请确认理解后再开启) -- capacity:遍历过程中最大的访问的顶点数目,选填项,默认为10000000 +- label:边的类型,选填项,默认代表所有 edge label +- max_degree:查询过程中,单个顶点遍历的最大邻接边数目,选填项,默认为 10000 +- skip_degree:用于设置查询过程中舍弃超级顶点的最小边数,即当某个顶点的邻接边数目大于 skip_degree 时,完全舍弃该顶点。选填项,如果开启时,需满足 `skip_degree >= max_degree` 约束,默认为 0 (不启用),表示不跳过任何点 (注意:开启此配置后,遍历时会尝试访问一个顶点的 skip_degree 条边,而不仅仅是 max_degree 条边,这样有额外的遍历开销,对查询性能影响可能有较大影响,请确认理解后再开启) +- capacity:遍历过程中最大的访问的顶点数目,选填项,默认为 10000000 ##### 3.2.8.2 使用方法 ###### Method & Url ``` -GET http://localhost:8080/graphs/{graph}/traversers/shortestpath?source="1:marko"&target="2:ripple"&max_depth=3 +GET http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/shortestpath?source="1:marko"&target="2:ripple"&max_depth=3 ``` ###### Response Status @@ -938,21 +938,21 @@ GET http://localhost:8080/graphs/{graph}/traversers/shortestpath?source="1:marko ###### Params -- source:起始顶点id,必填项 -- target:目的顶点id,必填项 -- direction:起始顶点向外发散的方向(OUT,IN,BOTH),选填项,默认是BOTH +- source:起始顶点 id,必填项 +- target:目的顶点 id,必填项 +- direction:起始顶点向外发散的方向(OUT,IN,BOTH),选填项,默认是 BOTH - max_depth:最大步数,必填项 -- label:边的类型,选填项,默认代表所有edge label -- max_degree:查询过程中,单个顶点遍历的最大邻接边数目,选填项,默认为10000 -- skip_degree:用于设置查询过程中舍弃超级顶点的最小边数,即当某个顶点的邻接边数目大于 skip_degree 时,完全舍弃该顶点。选填项,如果开启时,需满足 `skip_degree >= max_degree` 约束,默认为0 (不启用),表示不跳过任何点 (注意: 开启此配置后,遍历时会尝试访问一个顶点的 skip_degree 条边,而不仅仅是 max_degree 条边,这样有额外的遍历开销,对查询性能影响可能有较大影响,请确认理解后再开启) -- capacity:遍历过程中最大的访问的顶点数目,选填项,默认为10000000 +- label:边的类型,选填项,默认代表所有 edge label +- max_degree:查询过程中,单个顶点遍历的最大邻接边数目,选填项,默认为 10000 +- skip_degree:用于设置查询过程中舍弃超级顶点的最小边数,即当某个顶点的邻接边数目大于 skip_degree 时,完全舍弃该顶点。选填项,如果开启时,需满足 `skip_degree >= max_degree` 约束,默认为 0 (不启用),表示不跳过任何点 (注意:开启此配置后,遍历时会尝试访问一个顶点的 skip_degree 条边,而不仅仅是 max_degree 条边,这样有额外的遍历开销,对查询性能影响可能有较大影响,请确认理解后再开启) +- capacity:遍历过程中最大的访问的顶点数目,选填项,默认为 10000000 ##### 3.2.9.2 使用方法 ###### Method & Url ``` -GET http://localhost:8080/graphs/{graph}/traversers/allshortestpaths?source="A"&target="Z"&max_depth=10 +GET http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/allshortestpaths?source="A"&target="Z"&max_depth=10 ``` ###### Response Status @@ -1001,22 +1001,22 @@ GET http://localhost:8080/graphs/{graph}/traversers/allshortestpaths?source="A"& ###### Params -- source:起始顶点id,必填项 -- target:目的顶点id,必填项 -- direction:起始顶点向外发散的方向(OUT,IN,BOTH),选填项,默认是BOTH -- label:边的类型,选填项,默认代表所有edge label +- source:起始顶点 id,必填项 +- target:目的顶点 id,必填项 +- direction:起始顶点向外发散的方向(OUT,IN,BOTH),选填项,默认是 BOTH +- label:边的类型,选填项,默认代表所有 edge label - weight:边的权重属性,必填项,必须是数字类型的属性 -- max_degree:查询过程中,单个顶点遍历的最大邻接边数目,选填项,默认为10000 -- skip_degree:用于设置查询过程中舍弃超级顶点的最小边数,即当某个顶点的邻接边数目大于 skip_degree 时,完全舍弃该顶点。选填项,如果开启时,需满足 `skip_degree >= max_degree` 约束,默认为0 (不启用),表示不跳过任何点 (注意: 开启此配置后,遍历时会尝试访问一个顶点的 skip_degree 条边,而不仅仅是 max_degree 条边,这样有额外的遍历开销,对查询性能影响可能有较大影响,请确认理解后再开启) -- capacity:遍历过程中最大的访问的顶点数目,选填项,默认为10000000 -- with_vertex:true表示返回结果包含完整的顶点信息(路径中的全部顶点),false时表示只返回顶点id,选填项,默认为false +- max_degree:查询过程中,单个顶点遍历的最大邻接边数目,选填项,默认为 10000 +- skip_degree:用于设置查询过程中舍弃超级顶点的最小边数,即当某个顶点的邻接边数目大于 skip_degree 时,完全舍弃该顶点。选填项,如果开启时,需满足 `skip_degree >= max_degree` 约束,默认为 0 (不启用),表示不跳过任何点 (注意:开启此配置后,遍历时会尝试访问一个顶点的 skip_degree 条边,而不仅仅是 max_degree 条边,这样有额外的遍历开销,对查询性能影响可能有较大影响,请确认理解后再开启) +- capacity:遍历过程中最大的访问的顶点数目,选填项,默认为 10000000 +- with_vertex:true 表示返回结果包含完整的顶点信息(路径中的全部顶点),false 时表示只返回顶点 id,选填项,默认为 false ##### 3.2.10.2 使用方法 ###### Method & Url ``` -GET http://localhost:8080/graphs/{graph}/traversers/weightedshortestpath?source="1:marko"&target="2:ripple"&weight="weight"&with_vertex=true +GET http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/weightedshortestpath?source="1:marko"&target="2:ripple"&weight="weight"&with_vertex=true ``` ###### Response Status @@ -1076,7 +1076,7 @@ GET http://localhost:8080/graphs/{graph}/traversers/weightedshortestpath?source= 查找两个顶点间的带权最短路径,例如: -- 交通线路中查找从A城市到B城市花钱最少的交通方式 +- 交通线路中查找从 A 城市到 B 城市花钱最少的交通方式 #### 3.2.11 Single Source Shortest Path @@ -1086,22 +1086,22 @@ GET http://localhost:8080/graphs/{graph}/traversers/weightedshortestpath?source= ###### Params -- source:起始顶点id,必填项 -- direction:起始顶点向外发散的方向(OUT,IN,BOTH),选填项,默认是BOTH -- label:边的类型,选填项,默认代表所有edge label -- weight:边的权重属性,选填项,必须是数字类型的属性,如果不填或者虽然填了但是边没有该属性,则权重为1.0 -- max_degree:查询过程中,单个顶点遍历的最大邻接边数目,选填项,默认为10000 -- skip_degree:用于设置查询过程中舍弃超级顶点的最小边数,即当某个顶点的邻接边数目大于 skip_degree 时,完全舍弃该顶点。选填项,如果开启时,需满足 `skip_degree >= max_degree` 约束,默认为0 (不启用),表示不跳过任何点 (注意: 开启此配置后,遍历时会尝试访问一个顶点的 skip_degree 条边,而不仅仅是 max_degree 条边,这样有额外的遍历开销,对查询性能影响可能有较大影响,请确认理解后再开启) -- capacity:遍历过程中最大的访问的顶点数目,选填项,默认为10000000 -- limit:查询到的目标顶点个数,也是返回的最短路径的条数,选填项,默认为10 -- with_vertex:true表示返回结果包含完整的顶点信息(路径中的全部顶点),false时表示只返回顶点id,选填项,默认为false +- source:起始顶点 id,必填项 +- direction:起始顶点向外发散的方向(OUT,IN,BOTH),选填项,默认是 BOTH +- label:边的类型,选填项,默认代表所有 edge label +- weight:边的权重属性,选填项,必须是数字类型的属性,如果不填或者虽然填了但是边没有该属性,则权重为 1.0 +- max_degree:查询过程中,单个顶点遍历的最大邻接边数目,选填项,默认为 10000 +- skip_degree:用于设置查询过程中舍弃超级顶点的最小边数,即当某个顶点的邻接边数目大于 skip_degree 时,完全舍弃该顶点。选填项,如果开启时,需满足 `skip_degree >= max_degree` 约束,默认为 0 (不启用),表示不跳过任何点 (注意:开启此配置后,遍历时会尝试访问一个顶点的 skip_degree 条边,而不仅仅是 max_degree 条边,这样有额外的遍历开销,对查询性能影响可能有较大影响,请确认理解后再开启) +- capacity:遍历过程中最大的访问的顶点数目,选填项,默认为 10000000 +- limit:查询到的目标顶点个数,也是返回的最短路径的条数,选填项,默认为 10 +- with_vertex:true 表示返回结果包含完整的顶点信息(路径中的全部顶点),false 时表示只返回顶点 id,选填项,默认为 false ##### 3.2.11.2 使用方法 ###### Method & Url ``` -GET http://localhost:8080/graphs/{graph}/traversers/singlesourceshortestpath?source="1:marko"&with_vertex=true +GET http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/singlesourceshortestpath?source="1:marko"&with_vertex=true ``` ###### Response Status @@ -1233,27 +1233,27 @@ GET http://localhost:8080/graphs/{graph}/traversers/singlesourceshortestpath?sou ###### Params - vertices:定义起始顶点,必填项,指定方式包括: - - ids:通过顶点id列表提供起始顶点 - - label和properties:如果没有指定ids,则使用label和properties的联合条件查询起始顶点 + - ids:通过顶点 id 列表提供起始顶点 + - label 和 properties:如果没有指定 ids,则使用 label 和 properties 的联合条件查询起始顶点 - label:顶点的类型 - properties:通过属性的值查询起始顶点 - > 注意:properties中的属性值可以是列表,表示只要key对应的value在列表中就可以 -- step:表示从起始顶点到终止顶点走过的路径,必填项,Step的结构如下: - - direction:表示边的方向(OUT,IN,BOTH),默认是BOTH + > 注意:properties 中的属性值可以是列表,表示只要 key 对应的 value 在列表中就可以 +- step:表示从起始顶点到终止顶点走过的路径,必填项,Step 的结构如下: + - direction:表示边的方向(OUT,IN,BOTH),默认是 BOTH - labels:边的类型列表 - properties:通过属性的值过滤边 - - max_degree:查询过程中,单个顶点遍历的最大邻接边数目,默认为 10000 (注: 0.12版之前 step 内仅支持 degree 作为参数名, 0.12开始统一使用 max_degree, 并向下兼容 degree 写法) - - skip_degree:用于设置查询过程中舍弃超级顶点的最小边数,即当某个顶点的邻接边数目大于 skip_degree 时,完全舍弃该顶点。选填项,如果开启时,需满足 `skip_degree >= max_degree` 约束,默认为0 (不启用),表示不跳过任何点 (注意: 开启此配置后,遍历时会尝试访问一个顶点的 skip_degree 条边,而不仅仅是 max_degree 条边,这样有额外的遍历开销,对查询性能影响可能有较大影响,请确认理解后再开启) + - max_degree:查询过程中,单个顶点遍历的最大邻接边数目,默认为 10000 (注:0.12 版之前 step 内仅支持 degree 作为参数名,0.12 开始统一使用 max_degree, 并向下兼容 degree 写法) + - skip_degree:用于设置查询过程中舍弃超级顶点的最小边数,即当某个顶点的邻接边数目大于 skip_degree 时,完全舍弃该顶点。选填项,如果开启时,需满足 `skip_degree >= max_degree` 约束,默认为 0 (不启用),表示不跳过任何点 (注意:开启此配置后,遍历时会尝试访问一个顶点的 skip_degree 条边,而不仅仅是 max_degree 条边,这样有额外的遍历开销,对查询性能影响可能有较大影响,请确认理解后再开启) - max_depth:步数,必填项 -- capacity:遍历过程中最大的访问的顶点数目,选填项,默认为10000000 -- with_vertex:true表示返回结果包含完整的顶点信息(路径中的全部顶点),false时表示只返回顶点id,选填项,默认为false +- capacity:遍历过程中最大的访问的顶点数目,选填项,默认为 10000000 +- with_vertex:true 表示返回结果包含完整的顶点信息(路径中的全部顶点),false 时表示只返回顶点 id,选填项,默认为 false ##### 3.2.12.2 使用方法 ###### Method & Url ``` -POST http://localhost:8080/graphs/{graph}/traversers/multinodeshortestpath +POST http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/multinodeshortestpath ``` ###### Request Body @@ -1459,7 +1459,7 @@ POST http://localhost:8080/graphs/{graph}/traversers/multinodeshortestpath - 查找多个公司和法人之间的最短路径 -#### 3.2.13 Paths (GET,基础版) +#### 3.2.13 Paths(GET,基础版) ##### 3.2.13.1 功能介绍 @@ -1467,21 +1467,21 @@ POST http://localhost:8080/graphs/{graph}/traversers/multinodeshortestpath ###### Params -- source:起始顶点id,必填项 -- target:目的顶点id,必填项 -- direction:起始顶点向外发散的方向(OUT,IN,BOTH),选填项,默认是BOTH -- label:边的类型,选填项,默认代表所有edge label +- source:起始顶点 id,必填项 +- target:目的顶点 id,必填项 +- direction:起始顶点向外发散的方向(OUT,IN,BOTH),选填项,默认是 BOTH +- label:边的类型,选填项,默认代表所有 edge label - max_depth:步数,必填项 -- max_degree:查询过程中,单个顶点遍历的最大邻接边数目,选填项,默认为10000 -- capacity:遍历过程中最大的访问的顶点数目,选填项,默认为10000000 -- limit:返回的路径的最大数目,选填项,默认为10 +- max_degree:查询过程中,单个顶点遍历的最大邻接边数目,选填项,默认为 10000 +- capacity:遍历过程中最大的访问的顶点数目,选填项,默认为 10000000 +- limit:返回的路径的最大数目,选填项,默认为 10 ##### 3.2.13.2 使用方法 ###### Method & Url ``` -GET http://localhost:8080/graphs/{graph}/traversers/paths?source="1:marko"&target="1:josh"&max_depth=5 +GET http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/paths?source="1:marko"&target="1:josh"&max_depth=5 ``` ###### Response Status @@ -1519,7 +1519,7 @@ GET http://localhost:8080/graphs/{graph}/traversers/paths?source="1:marko"&targe - 社交网络中,查找两个用户所有可能的关系路径 - 设备关联网络中,查找两个设备之间所有的关联路径 -#### 3.2.14 Paths (POST,高级版) +#### 3.2.14 Paths(POST,高级版) ##### 3.2.14.1 功能介绍 @@ -1528,28 +1528,28 @@ GET http://localhost:8080/graphs/{graph}/traversers/paths?source="1:marko"&targe ###### Params - sources:定义起始顶点,必填项,指定方式包括: - - ids:通过顶点id列表提供起始顶点 - - label和properties:如果没有指定ids,则使用label和properties的联合条件查询起始顶点 + - ids:通过顶点 id 列表提供起始顶点 + - label 和 properties:如果没有指定 ids,则使用 label 和 properties 的联合条件查询起始顶点 - label:顶点的类型 - properties:通过属性的值查询起始顶点 - > 注意:properties中的属性值可以是列表,表示只要key对应的value在列表中就可以 + > 注意:properties 中的属性值可以是列表,表示只要 key 对应的 value 在列表中就可以 - targets:定义终止顶点,必填项,指定方式包括: - - ids:通过顶点id列表提供终止顶点 - - label和properties:如果没有指定ids,则使用label和properties的联合条件查询终止顶点 + - ids:通过顶点 id 列表提供终止顶点 + - label 和 properties:如果没有指定 ids,则使用 label 和 properties 的联合条件查询终止顶点 - label:顶点的类型 - properties:通过属性的值查询终止顶点 - > 注意:properties中的属性值可以是列表,表示只要key对应的value在列表中就可以 -- step:表示从起始顶点到终止顶点走过的路径,必填项,Step的结构如下: - - direction:表示边的方向(OUT,IN,BOTH),默认是BOTH + > 注意:properties 中的属性值可以是列表,表示只要 key 对应的 value 在列表中就可以 +- step:表示从起始顶点到终止顶点走过的路径,必填项,Step 的结构如下: + - direction:表示边的方向(OUT,IN,BOTH),默认是 BOTH - labels:边的类型列表 - properties:通过属性的值过滤边 - - max_degree:查询过程中,单个顶点遍历的最大邻接边数目,默认为 10000 (注: 0.12版之前 step 内仅支持 degree 作为参数名, 0.12开始统一使用 max_degree, 并向下兼容 degree 写法) - - skip_degree:用于设置查询过程中舍弃超级顶点的最小边数,即当某个顶点的邻接边数目大于 skip_degree 时,完全舍弃该顶点。选填项,如果开启时,需满足 `skip_degree >= max_degree` 约束,默认为0 (不启用),表示不跳过任何点 (注意: 开启此配置后,遍历时会尝试访问一个顶点的 skip_degree 条边,而不仅仅是 max_degree 条边,这样有额外的遍历开销,对查询性能影响可能有较大影响,请确认理解后再开启) + - max_degree:查询过程中,单个顶点遍历的最大邻接边数目,默认为 10000 (注:0.12 版之前 step 内仅支持 degree 作为参数名,0.12 开始统一使用 max_degree, 并向下兼容 degree 写法) + - skip_degree:用于设置查询过程中舍弃超级顶点的最小边数,即当某个顶点的邻接边数目大于 skip_degree 时,完全舍弃该顶点。选填项,如果开启时,需满足 `skip_degree >= max_degree` 约束,默认为 0 (不启用),表示不跳过任何点 (注意:开启此配置后,遍历时会尝试访问一个顶点的 skip_degree 条边,而不仅仅是 max_degree 条边,这样有额外的遍历开销,对查询性能影响可能有较大影响,请确认理解后再开启) - max_depth:步数,必填项 -- nearest:nearest为true时,代表起始顶点到达结果顶点的最短路径长度为depth,不存在更短的路径;nearest为false时,代表起始顶点到结果顶点有一条长度为depth的路径(未必最短且可以有环),选填项,默认为true -- capacity:遍历过程中最大的访问的顶点数目,选填项,默认为10000000 -- limit:返回的路径的最大数目,选填项,默认为10 -- with_vertex:true表示返回结果包含完整的顶点信息(路径中的全部顶点),false时表示只返回顶点id,选填项,默认为false +- nearest:nearest 为 true 时,代表起始顶点到达结果顶点的最短路径长度为 depth,不存在更短的路径;nearest 为 false 时,代表起始顶点到结果顶点有一条长度为 depth 的路径(未必最短且可以有环),选填项,默认为 true +- capacity:遍历过程中最大的访问的顶点数目,选填项,默认为 10000000 +- limit:返回的路径的最大数目,选填项,默认为 10 +- with_vertex:true 表示返回结果包含完整的顶点信息(路径中的全部顶点),false 时表示只返回顶点 id,选填项,默认为 false ##### 3.2.14.2 使用方法 @@ -1557,7 +1557,7 @@ GET http://localhost:8080/graphs/{graph}/traversers/paths?source="1:marko"&targe ###### Method & Url ``` -POST http://localhost:8080/graphs/{graph}/traversers/paths +POST http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/paths ``` ###### Request Body @@ -1630,33 +1630,33 @@ POST http://localhost:8080/graphs/{graph}/traversers/paths ###### Params - sources:定义起始顶点,必填项,指定方式包括: - - ids:通过顶点id列表提供起始顶点 - - label和properties:如果没有指定ids,则使用label和properties的联合条件查询起始顶点 + - ids:通过顶点 id 列表提供起始顶点 + - label 和 properties:如果没有指定 ids,则使用 label 和 properties 的联合条件查询起始顶点 - label:顶点的类型 - properties:通过属性的值查询起始顶点 - > 注意:properties中的属性值可以是列表,表示只要key对应的value在列表中就可以 -- steps:表示从起始顶点走过的路径规则,是一组Step的列表。必填项。每个Step的结构如下: - - direction:表示边的方向(OUT,IN,BOTH),默认是BOTH + > 注意:properties 中的属性值可以是列表,表示只要 key 对应的 value 在列表中就可以 +- steps:表示从起始顶点走过的路径规则,是一组 Step 的列表。必填项。每个 Step 的结构如下: + - direction:表示边的方向(OUT,IN,BOTH),默认是 BOTH - labels:边的类型列表 - properties:通过属性的值过滤边 - - weight_by:根据指定的属性计算边的权重,sort_by不为NONE时有效,与default_weight互斥 - - default_weight:当边没有属性作为权重计算值时,采取的默认权重,sort_by不为NONE时有效,与weight_by互斥 - - max_degree:查询过程中,单个顶点遍历的最大邻接边数目,默认为 10000 (注: 0.12版之前 step 内仅支持 degree 作为参数名, 0.12开始统一使用 max_degree, 并向下兼容 degree 写法) - - sample:当需要对某个step的符合条件的边进行采样时设置,-1表示不采样,默认为采样100 -- sort_by:根据路径的权重排序,选填项,默认为NONE: - - NONE表示不排序,默认值 - - INCR表示按照路径权重的升序排序 - - DECR表示按照路径权重的降序排序 -- capacity:遍历过程中最大的访问的顶点数目,选填项,默认为10000000 -- limit:返回的路径的最大数目,选填项,默认为10 -- with_vertex:true表示返回结果包含完整的顶点信息(路径中的全部顶点),false时表示只返回顶点id,选填项,默认为false + - weight_by:根据指定的属性计算边的权重,sort_by 不为 NONE 时有效,与 default_weight 互斥 + - default_weight:当边没有属性作为权重计算值时,采取的默认权重,sort_by 不为 NONE 时有效,与 weight_by 互斥 + - max_degree:查询过程中,单个顶点遍历的最大邻接边数目,默认为 10000 (注:0.12 版之前 step 内仅支持 degree 作为参数名,0.12 开始统一使用 max_degree, 并向下兼容 degree 写法) + - sample:当需要对某个 step 的符合条件的边进行采样时设置,-1 表示不采样,默认为采样 100 +- sort_by:根据路径的权重排序,选填项,默认为 NONE: + - NONE 表示不排序,默认值 + - INCR 表示按照路径权重的升序排序 + - DECR 表示按照路径权重的降序排序 +- capacity:遍历过程中最大的访问的顶点数目,选填项,默认为 10000000 +- limit:返回的路径的最大数目,选填项,默认为 10 +- with_vertex:true 表示返回结果包含完整的顶点信息(路径中的全部顶点),false 时表示只返回顶点 id,选填项,默认为 false ##### 3.2.15.2 使用方法 ###### Method & Url ``` -POST http://localhost:8080/graphs/{graph}/traversers/customizedpaths +POST http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/customizedpaths ``` ###### Request Body @@ -1805,7 +1805,7 @@ POST http://localhost:8080/graphs/{graph}/traversers/customizedpaths 适合查找各种复杂的路径集合,例如: -- 社交网络中,查找看过张艺谋所导演的电影的用户关注的大V的路径(张艺谋--->电影---->用户--->大V) +- 社交网络中,查找看过张艺谋所导演的电影的用户关注的大 V 的路径(张艺谋--->电影---->用户--->大 V) - 风控网络中,查找多个高风险用户的直系亲属的朋友的路径(高风险用户--->直系亲属--->朋友) #### 3.2.16 Template Paths @@ -1817,35 +1817,35 @@ POST http://localhost:8080/graphs/{graph}/traversers/customizedpaths ###### Params - sources:定义起始顶点,必填项,指定方式包括: - - ids:通过顶点id列表提供起始顶点 - - label和properties:如果没有指定ids,则使用label和properties的联合条件查询起始顶点 + - ids:通过顶点 id 列表提供起始顶点 + - label 和 properties:如果没有指定 ids,则使用 label 和 properties 的联合条件查询起始顶点 - label:顶点的类型 - properties:通过属性的值查询起始顶点 - > 注意:properties中的属性值可以是列表,表示只要key对应的value在列表中就可以 + > 注意:properties 中的属性值可以是列表,表示只要 key 对应的 value 在列表中就可以 - targets:定义终止顶点,必填项,指定方式包括: - - ids:通过顶点id列表提供终止顶点 - - label和properties:如果没有指定ids,则使用label和properties的联合条件查询终止顶点 + - ids:通过顶点 id 列表提供终止顶点 + - label 和 properties:如果没有指定 ids,则使用 label 和 properties 的联合条件查询终止顶点 - label:顶点的类型 - properties:通过属性的值查询终止顶点 - > 注意:properties中的属性值可以是列表,表示只要key对应的value在列表中就可以 -- steps:表示从起始顶点走过的路径规则,是一组Step的列表。必填项。每个Step的结构如下: - - direction:表示边的方向(OUT,IN,BOTH),默认是BOTH + > 注意:properties 中的属性值可以是列表,表示只要 key 对应的 value 在列表中就可以 +- steps:表示从起始顶点走过的路径规则,是一组 Step 的列表。必填项。每个 Step 的结构如下: + - direction:表示边的方向(OUT,IN,BOTH),默认是 BOTH - labels:边的类型列表 - properties:通过属性的值过滤边 - - max_times:当前step可以重复的次数,当为N时,表示从起始顶点可以经过当前step 1-N 次 - - max_degree:查询过程中,单个顶点遍历的最大邻接边数目,默认为 10000 (注: 0.12版之前 step 内仅支持 degree 作为参数名, 0.12开始统一使用 max_degree, 并向下兼容 degree 写法) - - skip_degree:用于设置查询过程中舍弃超级顶点的最小边数,即当某个顶点的邻接边数目大于 skip_degree 时,完全舍弃该顶点。选填项,如果开启时,需满足 `skip_degree >= max_degree` 约束,默认为0 (不启用),表示不跳过任何点 (注意: 开启此配置后,遍历时会尝试访问一个顶点的 skip_degree 条边,而不仅仅是 max_degree 条边,这样有额外的遍历开销,对查询性能影响可能有较大影响,请确认理解后再开启) -- with_ring:Boolean值,true表示包含环路;false表示不包含环路,默认为false -- capacity:遍历过程中最大的访问的顶点数目,选填项,默认为10000000 -- limit:返回的路径的最大数目,选填项,默认为10 -- with_vertex:true表示返回结果包含完整的顶点信息(路径中的全部顶点),false时表示只返回顶点id,选填项,默认为false + - max_times:当前 step 可以重复的次数,当为 N 时,表示从起始顶点可以经过当前 step 1-N 次 + - max_degree:查询过程中,单个顶点遍历的最大邻接边数目,默认为 10000 (注:0.12 版之前 step 内仅支持 degree 作为参数名,0.12 开始统一使用 max_degree, 并向下兼容 degree 写法) + - skip_degree:用于设置查询过程中舍弃超级顶点的最小边数,即当某个顶点的邻接边数目大于 skip_degree 时,完全舍弃该顶点。选填项,如果开启时,需满足 `skip_degree >= max_degree` 约束,默认为 0 (不启用),表示不跳过任何点 (注意:开启此配置后,遍历时会尝试访问一个顶点的 skip_degree 条边,而不仅仅是 max_degree 条边,这样有额外的遍历开销,对查询性能影响可能有较大影响,请确认理解后再开启) +- with_ring:Boolean 值,true 表示包含环路;false 表示不包含环路,默认为 false +- capacity:遍历过程中最大的访问的顶点数目,选填项,默认为 10000000 +- limit:返回的路径的最大数目,选填项,默认为 10 +- with_vertex:true 表示返回结果包含完整的顶点信息(路径中的全部顶点),false 时表示只返回顶点 id,选填项,默认为 false ##### 3.2.16.2 使用方法 ###### Method & Url ``` -POST http://localhost:8080/graphs/{graph}/traversers/templatepaths +POST http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/templatepaths ``` ###### Request Body @@ -1985,7 +1985,7 @@ POST http://localhost:8080/graphs/{graph}/traversers/templatepaths ##### 3.2.16.3 适用场景 -适合查找各种复杂的模板路径,比如personA -(朋友)-> personB -(同学)-> personC,其中"朋友"和"同学"边可以分别是最多3层和4层的情况 +适合查找各种复杂的模板路径,比如 personA -(朋友)-> personB -(同学)-> personC,其中"朋友"和"同学"边可以分别是最多 3 层和 4 层的情况 #### 3.2.17 Crosspoints @@ -1995,21 +1995,21 @@ POST http://localhost:8080/graphs/{graph}/traversers/templatepaths ###### Params -- source:起始顶点id,必填项 -- target:目的顶点id,必填项 -- direction:起始顶点到目的顶点的方向, 目的点到起始点是反方向,BOTH时不考虑方向(OUT,IN,BOTH),选填项,默认是BOTH -- label:边的类型,选填项,默认代表所有edge label +- source:起始顶点 id,必填项 +- target:目的顶点 id,必填项 +- direction:起始顶点到目的顶点的方向,目的点到起始点是反方向,BOTH 时不考虑方向(OUT,IN,BOTH),选填项,默认是 BOTH +- label:边的类型,选填项,默认代表所有 edge label - max_depth:步数,必填项 -- max_degree:查询过程中,单个顶点遍历的最大邻接边数目,选填项,默认为10000 -- capacity:遍历过程中最大的访问的顶点数目,选填项,默认为10000000 -- limit:返回的交点的最大数目,选填项,默认为10 +- max_degree:查询过程中,单个顶点遍历的最大邻接边数目,选填项,默认为 10000 +- capacity:遍历过程中最大的访问的顶点数目,选填项,默认为 10000000 +- limit:返回的交点的最大数目,选填项,默认为 10 ##### 3.2.17.2 使用方法 ###### Method & Url ``` -GET http://localhost:8080/graphs/{graph}/traversers/crosspoints?source="2:lop"&target="2:ripple"&max_depth=5&direction=IN +GET http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/crosspoints?source="2:lop"&target="2:ripple"&max_depth=5&direction=IN ``` ###### Response Status @@ -2039,7 +2039,7 @@ GET http://localhost:8080/graphs/{graph}/traversers/crosspoints?source="2:lop"&t 查找两个顶点的交点及其路径,例如: -- 社交网络中,查找两个用户共同关注的话题或者大V +- 社交网络中,查找两个用户共同关注的话题或者大 V - 家族关系中,查找共同的祖先 #### 3.2.18 Customized Crosspoints @@ -2051,34 +2051,34 @@ GET http://localhost:8080/graphs/{graph}/traversers/crosspoints?source="2:lop"&t ###### Params - sources:定义起始顶点,必填项,指定方式包括: - - ids:通过顶点id列表提供起始顶点 - - label和properties:如果没有指定ids,则使用label和properties的联合条件查询起始顶点 + - ids:通过顶点 id 列表提供起始顶点 + - label 和 properties:如果没有指定 ids,则使用 label 和 properties 的联合条件查询起始顶点 - label:顶点的类型 - properties:通过属性的值查询起始顶点 - > 注意:properties中的属性值可以是列表,表示只要key对应的value在列表中就可以 + > 注意:properties 中的属性值可以是列表,表示只要 key 对应的 value 在列表中就可以 -- path_patterns:表示从起始顶点走过的路径规则,是一组规则的列表。必填项。每个规则是一个PathPattern - - 每个PathPattern是一组Step列表,每个Step结构如下: - - direction:表示边的方向(OUT,IN,BOTH),默认是BOTH +- path_patterns:表示从起始顶点走过的路径规则,是一组规则的列表。必填项。每个规则是一个 PathPattern + - 每个 PathPattern 是一组 Step 列表,每个 Step 结构如下: + - direction:表示边的方向(OUT,IN,BOTH),默认是 BOTH - labels:边的类型列表 - properties:通过属性的值过滤边 - - max_degree:查询过程中,单个顶点遍历的最大邻接边数目,默认为 10000 (注: 0.12版之前 step 内仅支持 degree 作为参数名, 0.12开始统一使用 max_degree, 并向下兼容 degree 写法) - - skip_degree:用于设置查询过程中舍弃超级顶点的最小边数,即当某个顶点的邻接边数目大于 skip_degree 时,完全舍弃该顶点。选填项,如果开启时,需满足 `skip_degree >= max_degree` 约束,默认为0 (不启用),表示不跳过任何点 (注意: 开启此配置后,遍历时会尝试访问一个顶点的 skip_degree 条边,而不仅仅是 max_degree 条边,这样有额外的遍历开销,对查询性能影响可能有较大影响,请确认理解后再开启) -- capacity:遍历过程中最大的访问的顶点数目,选填项,默认为10000000 -- limit:返回的路径的最大数目,选填项,默认为10 -- with_path:true表示返回交点所在的路径,false表示不返回交点所在的路径,选填项,默认为false -- with_vertex,选填项,默认为false: - - true表示返回结果包含完整的顶点信息(路径中的全部顶点) - - with_path为true时,返回所有路径中的顶点的完整信息 - - with_path为false时,返回所有交点的完整信息 - - false时表示只返回顶点id + - max_degree:查询过程中,单个顶点遍历的最大邻接边数目,默认为 10000 (注:0.12 版之前 step 内仅支持 degree 作为参数名,0.12 开始统一使用 max_degree, 并向下兼容 degree 写法) + - skip_degree:用于设置查询过程中舍弃超级顶点的最小边数,即当某个顶点的邻接边数目大于 skip_degree 时,完全舍弃该顶点。选填项,如果开启时,需满足 `skip_degree >= max_degree` 约束,默认为 0 (不启用),表示不跳过任何点 (注意:开启此配置后,遍历时会尝试访问一个顶点的 skip_degree 条边,而不仅仅是 max_degree 条边,这样有额外的遍历开销,对查询性能影响可能有较大影响,请确认理解后再开启) +- capacity:遍历过程中最大的访问的顶点数目,选填项,默认为 10000000 +- limit:返回的路径的最大数目,选填项,默认为 10 +- with_path:true 表示返回交点所在的路径,false 表示不返回交点所在的路径,选填项,默认为 false +- with_vertex,选填项,默认为 false: + - true 表示返回结果包含完整的顶点信息(路径中的全部顶点) + - with_path 为 true 时,返回所有路径中的顶点的完整信息 + - with_path 为 false 时,返回所有交点的完整信息 + - false 时表示只返回顶点 id ##### 3.2.18.2 使用方法 ###### Method & Url ``` -POST http://localhost:8080/graphs/{graph}/traversers/customizedcrosspoints +POST http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/customizedcrosspoints ``` ###### Request Body @@ -2234,21 +2234,21 @@ POST http://localhost:8080/graphs/{graph}/traversers/customizedcrosspoints ###### Params -- source:起始顶点id,必填项 -- direction:起始顶点发出的边的方向(OUT,IN,BOTH),选填项,默认是BOTH -- label:边的类型,选填项,默认代表所有edge label +- source:起始顶点 id,必填项 +- direction:起始顶点发出的边的方向(OUT,IN,BOTH),选填项,默认是 BOTH +- label:边的类型,选填项,默认代表所有 edge label - max_depth:步数,必填项 -- source_in_ring:环路是否包含起点,选填项,默认为true -- max_degree:查询过程中,单个顶点遍历的最大邻接边数目,选填项,默认为10000 -- capacity:遍历过程中最大的访问的顶点数目,选填项,默认为10000000 -- limit:返回的可达环路的最大数目,选填项,默认为10 +- source_in_ring:环路是否包含起点,选填项,默认为 true +- max_degree:查询过程中,单个顶点遍历的最大邻接边数目,选填项,默认为 10000 +- capacity:遍历过程中最大的访问的顶点数目,选填项,默认为 10000000 +- limit:返回的可达环路的最大数目,选填项,默认为 10 ##### 3.2.19.2 使用方法 ###### Method & Url ``` -GET http://localhost:8080/graphs/{graph}/traversers/rings?source="1:marko"&max_depth=2 +GET http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/rings?source="1:marko"&max_depth=2 ``` ###### Response Status @@ -2304,20 +2304,20 @@ GET http://localhost:8080/graphs/{graph}/traversers/rings?source="1:marko"&max_d ###### Params -- source:起始顶点id,必填项 -- direction:起始顶点发出的边的方向(OUT,IN,BOTH),选填项,默认是BOTH -- label:边的类型,选填项,默认代表所有edge label +- source:起始顶点 id,必填项 +- direction:起始顶点发出的边的方向(OUT,IN,BOTH),选填项,默认是 BOTH +- label:边的类型,选填项,默认代表所有 edge label - max_depth:步数,必填项 -- max_degree:查询过程中,单个顶点遍历的最大邻接边数目,选填项,默认为10000 -- capacity:遍历过程中最大的访问的顶点数目,选填项,默认为10000000 -- limit:返回的非环路的最大数目,选填项,默认为10 +- max_degree:查询过程中,单个顶点遍历的最大邻接边数目,选填项,默认为 10000 +- capacity:遍历过程中最大的访问的顶点数目,选填项,默认为 10000000 +- limit:返回的非环路的最大数目,选填项,默认为 10 ##### 3.2.20.2 使用方法 ###### Method & Url ``` -GET http://localhost:8080/graphs/{graph}/traversers/rays?source="1:marko"&max_depth=2&direction=OUT +GET http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/rays?source="1:marko"&max_depth=2&direction=OUT ``` ###### Response Status @@ -2372,39 +2372,39 @@ GET http://localhost:8080/graphs/{graph}/traversers/rays?source="1:marko"&max_de ##### 3.2.21.1 功能介绍 -按照条件查询一批顶点对应的"梭形相似点"。当两个顶点跟很多共同的顶点之间有某种关系的时候,我们认为这两个点为"梭形相似点"。举个例子说明"梭形相似点":"读者A"读了100本书,可以定义读过这100本书中的80本以上的读者,是"读者A"的"梭形相似点" +按照条件查询一批顶点对应的"梭形相似点"。当两个顶点跟很多共同的顶点之间有某种关系的时候,我们认为这两个点为"梭形相似点"。举个例子说明"梭形相似点":"读者 A"读了 100 本书,可以定义读过这 100 本书中的 80 本以上的读者,是"读者 A"的"梭形相似点" ###### Params - sources:定义起始顶点,必填项,指定方式包括: - - ids:通过顶点id列表提供起始顶点 - - label和properties:如果没有指定ids,则使用label和properties的联合条件查询起始顶点 + - ids:通过顶点 id 列表提供起始顶点 + - label 和 properties:如果没有指定 ids,则使用 label 和 properties 的联合条件查询起始顶点 - label:顶点的类型 - properties:通过属性的值查询起始顶点 - > 注意:properties中的属性值可以是列表,表示只要key对应的value在列表中就可以 + > 注意:properties 中的属性值可以是列表,表示只要 key 对应的 value 在列表中就可以 -- label:边的类型,选填项,默认代表所有edge label -- direction:起始顶点向外发散的方向(OUT,IN,BOTH),选填项,默认是BOTH -- min_neighbors:最少邻居数目,邻居数目少于这个阈值时,认为起点不具备"梭形相似点"。比如想要找一个"读者A"读过的书的"梭形相似点",那么`min_neighbors`为100时,表示"读者A"至少要读过100本书才可以有"梭形相似点",必填项 +- label:边的类型,选填项,默认代表所有 edge label +- direction:起始顶点向外发散的方向(OUT,IN,BOTH),选填项,默认是 BOTH +- min_neighbors:最少邻居数目,邻居数目少于这个阈值时,认为起点不具备"梭形相似点"。比如想要找一个"读者 A"读过的书的"梭形相似点",那么`min_neighbors`为 100 时,表示"读者 A"至少要读过 100 本书才可以有"梭形相似点",必填项 - alpha:相似度,代表:起点与"梭形相似点"的共同邻居数目占起点的全部邻居数目的比例,必填项 -- min_similars:"梭形相似点"的最少个数,只有当起点的"梭形相似点"数目大于或等于该值时,才会返回起点及其"梭形相似点",选填项,默认值为1 -- top:返回一个起点的"梭形相似点"中相似度最高的top个,必填项,0表示全部 -- group_property:与`min_groups`一起使用,当起点跟其所有的"梭形相似点"某个属性的值有至少`min_groups`个不同值时,才会返回该起点及其"梭形相似点"。比如为"读者A"推荐"异地"书友时,需要设置`group_property`为读者的"城市"属性,`min_group`至少为2,选填项,不填代表不需要根据属性过滤 +- min_similars:"梭形相似点"的最少个数,只有当起点的"梭形相似点"数目大于或等于该值时,才会返回起点及其"梭形相似点",选填项,默认值为 1 +- top:返回一个起点的"梭形相似点"中相似度最高的 top 个,必填项,0 表示全部 +- group_property:与`min_groups`一起使用,当起点跟其所有的"梭形相似点"某个属性的值有至少`min_groups`个不同值时,才会返回该起点及其"梭形相似点"。比如为"读者 A"推荐"异地"书友时,需要设置`group_property`为读者的"城市"属性,`min_group`至少为 2,选填项,不填代表不需要根据属性过滤 - min_groups:与`group_property`一起使用,只有`group_property`设置时才有意义 -- max_degree:查询过程中,单个顶点遍历的最大邻接边数目,选填项,默认为10000 -- capacity:遍历过程中最大的访问的顶点数目,选填项,默认为10000000 -- limit:返回的结果数目上限(一个起点及其"梭形相似点"算一个结果),选填项,默认为10 -- with_intermediary:是否返回起点及其"梭形相似点"共同关联的中间点,默认为false -- with_vertex,选填项,默认为false: - - true表示返回结果包含完整的顶点信息 - - false时表示只返回顶点id +- max_degree:查询过程中,单个顶点遍历的最大邻接边数目,选填项,默认为 10000 +- capacity:遍历过程中最大的访问的顶点数目,选填项,默认为 10000000 +- limit:返回的结果数目上限(一个起点及其"梭形相似点"算一个结果),选填项,默认为 10 +- with_intermediary:是否返回起点及其"梭形相似点"共同关联的中间点,默认为 false +- with_vertex,选填项,默认为 false: + - true 表示返回结果包含完整的顶点信息 + - false 时表示只返回顶点 id ##### 3.2.21.2 使用方法 ###### Method & Url ``` -POST http://localhost:8080/graphs/hugegraph/traversers/fusiformsimilarity +POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/traversers/fusiformsimilarity ``` ###### Request Body @@ -2502,16 +2502,16 @@ POST http://localhost:8080/graphs/hugegraph/traversers/fusiformsimilarity #### 3.2.22 Vertices -##### 3.2.22.1 根据顶点的id列表,批量查询顶点 +##### 3.2.22.1 根据顶点的 id 列表,批量查询顶点 ###### Params -- ids:要查询的顶点id列表 +- ids:要查询的顶点 id 列表 ###### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/traversers/vertices?ids="1:marko"&ids="2:lop" +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/traversers/vertices?ids="1:marko"&ids="2:lop" ``` ###### Response Status @@ -2581,7 +2581,7 @@ GET http://localhost:8080/graphs/hugegraph/traversers/vertices?ids="1:marko"&ids ##### 3.2.22.2 获取顶点 Shard 信息 -通过指定的分片大小split_size,获取顶点分片信息(可以与 3.2.21.3 中的 Scan 配合使用来获取顶点)。 +通过指定的分片大小 split_size,获取顶点分片信息(可以与 3.2.21.3 中的 Scan 配合使用来获取顶点)。 ###### Params @@ -2590,7 +2590,7 @@ GET http://localhost:8080/graphs/hugegraph/traversers/vertices?ids="1:marko"&ids ###### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/traversers/vertices/shards?split_size=67108864 +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/traversers/vertices/shards?split_size=67108864 ``` ###### Response Status @@ -2629,21 +2629,21 @@ GET http://localhost:8080/graphs/hugegraph/traversers/vertices/shards?split_size } ``` -##### 3.2.22.3 根据Shard信息批量获取顶点 +##### 3.2.22.3 根据 Shard 信息批量获取顶点 -通过指定的分片信息批量查询顶点(Shard信息的获取参见 3.2.21.2 Shard)。 +通过指定的分片信息批量查询顶点(Shard 信息的获取参见 3.2.21.2 Shard)。 ###### Params - start:分片起始位置,必填项 - end:分片结束位置,必填项 -- page:分页位置,选填项,默认为null,不分页;当page为“”时表示分页的第一页,从start指示的位置开始 -- page_limit:分页获取顶点时,一页中顶点数目的上限,选填项,默认为100000 +- page:分页位置,选填项,默认为 null,不分页;当 page 为“”时表示分页的第一页,从 start 指示的位置开始 +- page_limit:分页获取顶点时,一页中顶点数目的上限,选填项,默认为 100000 ###### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/traversers/vertices/scan?start=0&end=4294967295 +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/traversers/vertices/scan?start=0&end=4294967295 ``` ###### Response Status @@ -2813,21 +2813,21 @@ GET http://localhost:8080/graphs/hugegraph/traversers/vertices/scan?start=0&end= ##### 3.2.22.4 适用场景 -- 按id列表查询顶点,可用于批量查询顶点,比如在path查询到多条路径之后,可以进一步查询某条路径的所有顶点属性。 +- 按 id 列表查询顶点,可用于批量查询顶点,比如在 path 查询到多条路径之后,可以进一步查询某条路径的所有顶点属性。 - 获取分片和按分片查询顶点,可以用来遍历全部顶点 #### 3.2.23 Edges -##### 3.2.23.1 根据边的id列表,批量查询边 +##### 3.2.23.1 根据边的 id 列表,批量查询边 ###### Params -- ids:要查询的边id列表 +- ids:要查询的边 id 列表 ###### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/traversers/edges?ids="S1:josh>1>>S2:lop"&ids="S1:josh>1>>S2:ripple" +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/traversers/edges?ids="S1:josh>1>>S2:lop"&ids="S1:josh>1>>S2:ripple" ``` ###### Response Status @@ -2873,7 +2873,7 @@ GET http://localhost:8080/graphs/hugegraph/traversers/edges?ids="S1:josh>1>>S2:l ##### 3.2.23.2 获取边 Shard 信息 -通过指定的分片大小split_size,获取边分片信息(可以与 3.2.22.3 中的 Scan 配合使用来获取边)。 +通过指定的分片大小 split_size,获取边分片信息(可以与 3.2.22.3 中的 Scan 配合使用来获取边)。 ###### Params @@ -2882,7 +2882,7 @@ GET http://localhost:8080/graphs/hugegraph/traversers/edges?ids="S1:josh>1>>S2:l ###### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/traversers/edges/shards?split_size=4294967295 +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/traversers/edges/shards?split_size=4294967295 ``` ###### Response Status @@ -2927,19 +2927,19 @@ GET http://localhost:8080/graphs/hugegraph/traversers/edges/shards?split_size=42 ##### 3.2.23.3 根据 Shard 信息批量获取边 -通过指定的分片信息批量查询边(Shard信息的获取参见 3.2.22.2)。 +通过指定的分片信息批量查询边(Shard 信息的获取参见 3.2.22.2)。 ###### Params - start:分片起始位置,必填项 - end:分片结束位置,必填项 -- page:分页位置,选填项,默认为null,不分页;当page为“”时表示分页的第一页,从start指示的位置开始 -- page_limit:分页获取边时,一页中边数目的上限,选填项,默认为100000 +- page:分页位置,选填项,默认为 null,不分页;当 page 为“”时表示分页的第一页,从 start 指示的位置开始 +- page_limit:分页获取边时,一页中边数目的上限,选填项,默认为 100000 ###### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/traversers/edges/scan?start=0&end=3221225469 +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/traversers/edges/scan?start=0&end=3221225469 ``` ###### Response Status @@ -3037,5 +3037,5 @@ GET http://localhost:8080/graphs/hugegraph/traversers/edges/scan?start=0&end=322 ##### 3.2.23.4 适用场景 -- 按id列表查询边,可用于批量查询边 +- 按 id 列表查询边,可用于批量查询边 - 获取分片和按分片查询边,可以用来遍历全部边 diff --git a/content/cn/docs/clients/restful-api/variable.md b/content/cn/docs/clients/restful-api/variable.md index ee2223583..5ca2ec0b9 100644 --- a/content/cn/docs/clients/restful-api/variable.md +++ b/content/cn/docs/clients/restful-api/variable.md @@ -6,14 +6,14 @@ weight: 11 ### 5.1 Variables -Variables可以用来存储有关整个图的数据,数据按照键值对的方式存取 +Variables 可以用来存储有关整个图的数据,数据按照键值对的方式存取 #### 5.1.1 创建或者更新某个键值对 ##### Method & Url ``` -PUT http://localhost:8080/graphs/hugegraph/variables/name +PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/variables/name ``` ##### Request Body @@ -43,7 +43,7 @@ PUT http://localhost:8080/graphs/hugegraph/variables/name ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/variables +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/variables ``` ##### Response Status @@ -65,7 +65,7 @@ GET http://localhost:8080/graphs/hugegraph/variables ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/variables/name +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/variables/name ``` ##### Response Status @@ -87,11 +87,11 @@ GET http://localhost:8080/graphs/hugegraph/variables/name ##### Method & Url ``` -DELETE http://localhost:8080/graphs/hugegraph/variables/name +DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/variables/name ``` ##### Response Status ```json 204 -``` \ No newline at end of file +``` diff --git a/content/cn/docs/clients/restful-api/vertex.md b/content/cn/docs/clients/restful-api/vertex.md index 4b8a2f79b..0df58ecce 100644 --- a/content/cn/docs/clients/restful-api/vertex.md +++ b/content/cn/docs/clients/restful-api/vertex.md @@ -42,10 +42,17 @@ schema.indexLabel("personByAge").onV("person").by("age").range().ifNotExist().cr #### 2.1.1 创建一个顶点 +##### Params + +**路径参数说明:** + +- graphspace: 图空间名称 +- graph: 图名称 + ##### Method & Url ``` -POST http://localhost:8080/graphs/hugegraph/graph/vertices +POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices ``` ##### Request Body @@ -82,10 +89,17 @@ POST http://localhost:8080/graphs/hugegraph/graph/vertices #### 2.1.2 创建多个顶点 +##### Params + +**路径参数说明:** + +- graphspace: 图空间名称 +- graph: 图名称 + ##### Method & Url ``` -POST http://localhost:8080/graphs/hugegraph/graph/vertices/batch +POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices/batch ``` ##### Request Body @@ -127,10 +141,18 @@ POST http://localhost:8080/graphs/hugegraph/graph/vertices/batch #### 2.1.3 更新顶点属性 +##### Params + +**路径参数说明:** + +- graphspace: 图空间名称 +- graph: 图名称 +- id: 顶点 id,需要包含引号,例如"1:marko" + ##### Method & Url ``` -PUT http://127.0.0.1:8080/graphs/hugegraph/graph/vertices/"1:marko"?action=append +PUT http://127.0.0.1:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices/"1:marko"?action=append ``` ##### Request Body @@ -145,7 +167,7 @@ PUT http://127.0.0.1:8080/graphs/hugegraph/graph/vertices/"1:marko"?action=appen } ``` -> 注意:属性的取值有三种类别,分别为single、set和list。single表示增加或更新属性值,set或list表示追加属性值。 +> 注意:属性的取值有三种类别,分别为 single、set 和 list。single 表示增加或更新属性值,set 或 list 表示追加属性值。 ##### Response Status @@ -175,13 +197,13 @@ PUT http://127.0.0.1:8080/graphs/hugegraph/graph/vertices/"1:marko"?action=appen 批量更新顶点的属性时,可以选择多种更新策略,如下: - SUM: 数值累加 -- BIGGER: 原值和新值(数字、日期)取更大的 -- SMALLER: 原值和新值(数字、日期)取更小的 -- UNION: Set属性取并集 -- INTERSECTION: Set属性取交集 -- APPEND: List属性追加元素 +- BIGGER: 原值和新值 (数字、日期) 取更大的 +- SMALLER: 原值和新值 (数字、日期) 取更小的 +- UNION: Set 属性取并集 +- INTERSECTION: Set 属性取交集 +- APPEND: List 属性追加元素 - ELIMINATE: List/Set属性删除元素 -- OVERRIDE: 覆盖已有属性,如果新属性为null,则仍然使用旧属性 +- OVERRIDE: 覆盖已有属性,如果新属性为 null,则仍然使用旧属性 假设原顶点的属性如下: @@ -220,13 +242,20 @@ PUT http://127.0.0.1:8080/graphs/hugegraph/graph/vertices/"1:marko"?action=appen 通过以下命令新增顶点: ```shell -curl -H "Content-Type: application/json" -d '[{"label":"person","properties":{"name":"josh","age":32,"city":"Beijing","weight":0.1,"hobby":["reading","football"]}},{"label":"software","properties":{"name":"lop","lang":"java","price":328}}]' http:///127.0.0.1:8080/graphs/hugegraph/graph/vertices/batch +curl -H "Content-Type: application/json" -d '[{"label":"person","properties":{"name":"josh","age":32,"city":"Beijing","weight":0.1,"hobby":["reading","football"]}},{"label":"software","properties":{"name":"lop","lang":"java","price":328}}]' http://127.0.0.1:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices/batch ``` +##### Params + +**路径参数说明:** + +- graphspace: 图空间名称 +- graph: 图名称 + ##### Method & Url ``` -PUT http://127.0.0.1:8080/graphs/hugegraph/graph/vertices/batch +PUT http://127.0.0.1:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices/batch ``` ##### Request Body @@ -310,21 +339,29 @@ PUT http://127.0.0.1:8080/graphs/hugegraph/graph/vertices/batch 结果分析如下: -- lang 属性未指定更新策略,直接用新值覆盖旧值,无论新值是否为null; -- price 属性指定 BIGGER 的更新策略,旧属性值为328,新属性值为299,所以仍然保留了旧属性值328; -- age 属性指定 OVERRIDE 更新策略,而新属性值中未传入age,相当于age为null,所以仍然保留了原属性值32; -- city 属性也指定了 OVERRIDE 更新策略,且新属性值不为null,所以覆盖了旧值; -- weight 属性指定了 SUM 更新策略,旧属性值为0.1,新属性值为0.2,最后的值为0.3; -- hobby 属性(基数为Set)指定了 UNION 更新策略,所以新值与旧值取了并集; +- lang 属性未指定更新策略,直接用新值覆盖旧值,无论新值是否为 null; +- price 属性指定 BIGGER 的更新策略,旧属性值为 328,新属性值为 299,所以仍然保留了旧属性值 328; +- age 属性指定 OVERRIDE 更新策略,而新属性值中未传入 age,相当于 age 为 null,所以仍然保留了原属性值 32; +- city 属性也指定了 OVERRIDE 更新策略,且新属性值不为 null,所以覆盖了旧值; +- weight 属性指定了 SUM 更新策略,旧属性值为 0.1,新属性值为 0.2,最后的值为 0.3; +- hobby 属性(基数为 Set)指定了 UNION 更新策略,所以新值与旧值取了并集; 其他更新策略的使用方式与此类似,此处不再详述。 #### 2.1.5 删除顶点属性 +##### Params + +**路径参数说明:** + +- graphspace: 图空间名称 +- graph: 图名称 +- id: 顶点 id,需要包含引号,例如"1:marko" + ##### Method & Url ``` -PUT http://127.0.0.1:8080/graphs/hugegraph/graph/vertices/"1:marko"?action=eliminate +PUT http://127.0.0.1:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices/"1:marko"?action=eliminate ``` ##### Request Body @@ -338,7 +375,7 @@ PUT http://127.0.0.1:8080/graphs/hugegraph/graph/vertices/"1:marko"?action=elimi } ``` -> 注意:这里会直接删除属性(删除key和所有value),无论其属性的取值是single、set或list。 +> 注意:这里会直接删除属性(删除 key 和所有 value),无论其属性的取值是 single、set 或 list。 ##### Response Status @@ -364,34 +401,41 @@ PUT http://127.0.0.1:8080/graphs/hugegraph/graph/vertices/"1:marko"?action=elimi ##### Params +**路径参数说明:** + +- graphspace: 图空间名称 +- graph: 图名称 + +**请求参数说明:** + - label: 顶点的类型 - properties: 属性键值对(查询属性的前提是该属性已经建立了索引) - limit: 查询结果的最大数目 - page: 分页的页号 -以上参数都是可选的,但如果提供了page参数,就必须同时提供limit参数,并且不能再提供其他参数。`label, properties`和`limit`之间可以任意组合。 +以上参数都是可选的,但如果提供了 page 参数,就必须同时提供 limit 参数,并且不能再提供其他参数。`label, properties`和`limit`之间可以任意组合。 -属性键值对由属性名称和属性值组成JSON格式的对象,可以使用多个属性键值对作为查询条件,属性值支持精确匹配和范围匹配,精确匹配的形式如`properties={"age":29}`,范围匹配的形式如`properties={"age":"P.gt(29)"}`,范围匹配支持以下表达式: +属性键值对由属性名称和属性值组成 JSON 格式的对象,可以使用多个属性键值对作为查询条件,属性值支持精确匹配和范围匹配,精确匹配的形式如`properties={"age":29}`,范围匹配的形式如`properties={"age":"P.gt(29)"}`,范围匹配支持以下表达式: -| 表达式 | 说明 | -|------------------------------------|-----------------------------| -| P.eq(number) | 属性值等于number的顶点 | -| P.neq(number) | 属性值不等于number的顶点 | -| P.lt(number) | 属性值小于number的顶点 | -| P.lte(number) | 属性值小于等于number的顶点 | -| P.gt(number) | 属性值大于number的顶点 | -| P.gte(number) | 属性值大于等于number的顶点 | -| P.between(number1,number2) | 属性值大于等于number1且小于number2的顶点 | -| P.inside(number1,number2) | 属性值大于number1且小于number2的顶点 | -| P.outside(number1,number2) | 属性值小于number1且大于number2的顶点 | -| P.within(value1,value2,value3,...) | 属性值等于任何一个给定value的顶点 | +| 表达式 | 说明 | +|------------------------------------|---------------------------------| +| P.eq(number) | 属性值等于 number 的顶点 | +| P.neq(number) | 属性值不等于 number 的顶点 | +| P.lt(number) | 属性值小于 number 的顶点 | +| P.lte(number) | 属性值小于等于 number 的顶点 | +| P.gt(number) | 属性值大于 number 的顶点 | +| P.gte(number) | 属性值大于等于 number 的顶点 | +| P.between(number1,number2) | 属性值大于等于 number1 且小于 number2 的顶点 | +| P.inside(number1,number2) | 属性值大于 number1 且小于 number2 的顶点 | +| P.outside(number1,number2) | 属性值小于 number1 且大于 number2 的顶点 | +| P.within(value1,value2,value3,...) | 属性值等于任何一个给定 value 的顶点 | **查询所有 age 为 29 且 label 为 person 的顶点** ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/graph/vertices?label=person&properties={"age":29}&limit=1 +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices?label=person&properties={"age":29}&limit=1 ``` ##### Response Status @@ -418,18 +462,18 @@ GET http://localhost:8080/graphs/hugegraph/graph/vertices?label=person&propertie } ``` -**分页查询所有顶点,获取第一页(page不带参数值),限定3条** +**分页查询所有顶点,获取第一页(page 不带参数值),限定 3 条** 通过以下命令新增顶点: ```shell -curl -H "Content-Type: application/json" -d '[{"label":"person","properties":{"name":"peter","age":29,"city":"Shanghai"}},{"label":"person","properties":{"name":"vadas","age":27,"city":"Hongkong"}}]' http://localhost:8080/graphs/hugegraph/graph/vertices/batch +curl -H "Content-Type: application/json" -d '[{"label":"person","properties":{"name":"peter","age":29,"city":"Shanghai"}},{"label":"person","properties":{"name":"vadas","age":27,"city":"Hongkong"}}]' http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices/batch ``` ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/graph/vertices?page&limit=3 +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices?page&limit=3 ``` ##### Response Status @@ -485,12 +529,12 @@ GET http://localhost:8080/graphs/hugegraph/graph/vertices?page&limit=3 返回的 `body` 里面是带有下一页的页号信息的,`"page": "CIYxOnBldGVyAAAAAAAAAAM="`,在查询下一页的时候将该值赋给 `page` 参数。 -**分页查询所有顶点,获取下一页(page带上上一页返回的page值),限定3条** +**分页查询所有顶点,获取下一页(page 带上上一页返回的 page 值),限定 3 条** ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/graph/vertices?page=CIYxOnBldGVyAAAAAAAAAAM=&limit=3 +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices?page=CIYxOnBldGVyAAAAAAAAAAM=&limit=3 ``` ##### Response Status @@ -539,14 +583,22 @@ GET http://localhost:8080/graphs/hugegraph/graph/vertices?page=CIYxOnBldGVyAAAAA } ``` -当`"page": null`时,表示已经没有下一页了(注:如果后端使用的是 Cassandra ,为了提高性能,当返回的页数刚好是最后一页时,返回的 `page` 值可能不为空,但是如果用这个 `page` 值再请求下一页数据时,就会返回 `空数据` 和 `page = null`,其他情况也类似) +当`"page": null`时,表示已经没有下一页了(注:如果后端使用的是 Cassandra,为了提高性能,当返回的页数刚好是最后一页时,返回的 `page` 值可能不为空,但是如果用这个 `page` 值再请求下一页数据时,就会返回 `空数据` 和 `page = null`,其他情况也类似) -#### 2.1.7 根据Id获取顶点 +#### 2.1.7 根据 Id 获取顶点 + +##### Params + +**路径参数说明:** + +- graphspace: 图空间名称 +- graph: 图名称 +- id: 顶点 id,需要包含引号,例如"1:marko" ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/graph/vertices/"1:marko" +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices/"1:marko" ``` ##### Response Status @@ -569,18 +621,26 @@ GET http://localhost:8080/graphs/hugegraph/graph/vertices/"1:marko" } ``` -#### 2.1.8 根据Id删除顶点 +#### 2.1.8 根据 Id 删除顶点 ##### Params +**路径参数说明:** + +- graphspace: 图空间名称 +- graph: 图名称 +- id: 顶点 id,需要包含引号,例如"1:marko" + +**请求参数说明:** + - label: 顶点类型,可选参数 -**仅根据Id删除顶点** +**仅根据 Id 删除顶点** ##### Method & Url ``` -DELETE http://localhost:8080/graphs/hugegraph/graph/vertices/"1:marko" +DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices/"1:marko" ``` ##### Response Status @@ -589,14 +649,14 @@ DELETE http://localhost:8080/graphs/hugegraph/graph/vertices/"1:marko" 204 ``` -**根据Label+Id删除顶点** +**根据 Label+Id 删除顶点** -通过指定Label参数和Id来删除顶点时,一般来说其性能比仅根据Id删除会更好。 +通过指定 Label 参数和 Id 来删除顶点时,一般来说其性能比仅根据 Id 删除会更好。 ##### Method & Url ``` -DELETE http://localhost:8080/graphs/hugegraph/graph/vertices/"1:marko"?label=person +DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices/"1:marko"?label=person ``` ##### Response Status diff --git a/content/cn/docs/clients/restful-api/vertexlabel.md b/content/cn/docs/clients/restful-api/vertexlabel.md index e75bcc7a2..31ff5a7eb 100644 --- a/content/cn/docs/clients/restful-api/vertexlabel.md +++ b/content/cn/docs/clients/restful-api/vertexlabel.md @@ -6,27 +6,26 @@ weight: 3 ### 1.3 VertexLabel -假设已经创建好了1.1.3中列出来的 PropertyKeys +假设已经创建好了 1.1.3 中列出来的 PropertyKeys -Params说明 +Params 说明 -- id:顶点类型id值 +- id:顶点类型 id 值 - name:顶点类型名称,必填 -- id_strategy: 顶点类型的ID策略,主键ID、自动生成、自定义字符串、自定义数字、自定义UUID,默认主键ID +- id_strategy: 顶点类型的 ID 策略,主键 ID、自动生成、自定义字符串、自定义数字、自定义 UUID,默认主键 ID - properties: 顶点类型关联的属性类型 -- primary_keys: 主键属性,当ID策略为PRIMARY_KEY时必须有值,其他ID策略时必须为空; -- enable_label_index: 是否开启类型索引,默认关闭 -- index_names:顶点类型创建的索引,详情见3.4 +- primary_keys: 主键属性,当 ID 策略为 PRIMARY_KEY 时必须有值,其他 ID 策略时必须为空; +- enable_label_index:是否开启类型索引,默认关闭 +- index_names:顶点类型创建的索引,详情见 3.4 - nullable_keys:可为空的属性 - user_data:设置顶点类型的通用信息,作用同属性类型 - -#### 1.3.1 创建一个VertexLabel +#### 1.3.1 创建一个 VertexLabel ##### Method & Url ``` -POST http://localhost:8080/graphs/hugegraph/schema/vertexlabels +POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/vertexlabels ``` ##### Request Body @@ -116,7 +115,7 @@ POST http://localhost:8080/graphs/hugegraph/schema/vertexlabels } ``` -#### 1.3.2 为已存在的VertexLabel添加properties或userdata,或者移除userdata(目前不支持移除properties) +#### 1.3.2 为已存在的 VertexLabel 添加 properties 或 userdata,或者移除 userdata(目前不支持移除 properties) ##### Params @@ -125,7 +124,7 @@ POST http://localhost:8080/graphs/hugegraph/schema/vertexlabels ##### Method & Url ``` -PUT http://localhost:8080/graphs/hugegraph/schema/vertexlabels/person?action=append +PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/vertexlabels/person?action=append ``` ##### Request Body @@ -176,12 +175,12 @@ PUT http://localhost:8080/graphs/hugegraph/schema/vertexlabels/person?action=app } ``` -#### 1.3.3 获取所有的VertexLabel +#### 1.3.3 获取所有的 VertexLabel ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/schema/vertexlabels +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/vertexlabels ``` ##### Response Status @@ -241,12 +240,12 @@ GET http://localhost:8080/graphs/hugegraph/schema/vertexlabels } ``` -#### 1.3.4 根据name获取VertexLabel +#### 1.3.4 根据 name 获取 VertexLabel ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/schema/vertexlabels/person +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/vertexlabels/person ``` ##### Response Status @@ -282,14 +281,14 @@ GET http://localhost:8080/graphs/hugegraph/schema/vertexlabels/person } ``` -#### 1.3.5 根据name删除VertexLabel +#### 1.3.5 根据 name 删除 VertexLabel 删除 VertexLabel 会导致删除对应的顶点以及相关的索引数据,会产生一个异步任务 ##### Method & Url ``` -DELETE http://localhost:8080/graphs/hugegraph/schema/vertexlabels/person +DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/vertexlabels/person ``` ##### Response Status @@ -308,4 +307,4 @@ DELETE http://localhost:8080/graphs/hugegraph/schema/vertexlabels/person 注: -> 可以通过`GET http://localhost:8080/graphs/hugegraph/tasks/1`(其中"1"是task_id)来查询异步任务的执行状态,更多[异步任务RESTful API](../task) \ No newline at end of file +> 可以通过`GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/1`(其中"1"是 task_id)来查询异步任务的执行状态,更多[异步任务 RESTful API](../task) diff --git a/content/cn/docs/quickstart/hugegraph/hugegraph-server.md b/content/cn/docs/quickstart/hugegraph/hugegraph-server.md index d4e80d8fc..a0606b94d 100644 --- a/content/cn/docs/quickstart/hugegraph/hugegraph-server.md +++ b/content/cn/docs/quickstart/hugegraph/hugegraph-server.md @@ -17,11 +17,11 @@ Core 模块是 Tinkerpop 接口的实现,Backend 模块用于管理数据存 #### 2.1 安装 Java 11 (JDK 11) -请优先考虑在 Java 11 的环境上启动 `HugeGraph-Server`(在 1.5.0 版前,会保留对 Java 8 的基本兼容) +请考虑在 Java 11 的环境上启动 `HugeGraph-Server`(在 1.5.0 版前,会保留对 Java 8 的基本兼容) **在往下阅读之前先执行 `java -version` 命令确认 jdk 版本** -> 注:使用 Java 8 启动 HugeGraph-Server 会失去一些**安全性**的保障,也会降低性能相关指标 (请尽早升级/迁移) +> 注:使用 Java 8 启动 HugeGraph-Server 会失去一些**安全性**的保障,也会降低性能相关指标 (请尽早升级/迁移,1.7.0 不再支持) ### 3 部署 @@ -187,7 +187,9 @@ HugeGraphServer 启动时会连接后端存储并尝试检查后端存储版本 要使用分布式存储引擎,需要先部署 HugeGraph-PD 和 HugeGraph-Store,详见 [HugeGraph-PD 快速入门](/cn/docs/quickstart/hugegraph/hugegraph-pd/) 和 [HugeGraph-Store 快速入门](/cn/docs/quickstart/hugegraph/hugegraph-hstore/)。 -确保 PD 和 Store 服务均已启动后,修改 HugeGraph-Server 的 `hugegraph.properties` 配置: +确保 PD 和 Store 服务均已启动后 + +1. 修改 HugeGraph-Server 的 `hugegraph.properties` 配置: ```properties backend=hstore @@ -198,10 +200,17 @@ task.scheduler_type=distributed pd.peers=127.0.0.1:8686,127.0.0.1:8687,127.0.0.1:8688 ``` +2. 修改 HugeGraph-Server 的 `rest-server.properties` 配置: + +```properties +usePD=true +``` + 如果配置多个 HugeGraph-Server 节点,需要为每个节点修改 `rest-server.properties` 配置文件,例如: 节点 1(主节点): ```properties +usePD=true restserver.url=http://127.0.0.1:8081 gremlinserver.url=http://127.0.0.1:8181 @@ -214,6 +223,7 @@ server.role=master 节点 2(工作节点): ```properties +usePD=true restserver.url=http://127.0.0.1:8082 gremlinserver.url=http://127.0.0.1:8182 diff --git a/content/en/docs/clients/restful-api/_index.md b/content/en/docs/clients/restful-api/_index.md index 29e567509..355b4cbc3 100644 --- a/content/en/docs/clients/restful-api/_index.md +++ b/content/en/docs/clients/restful-api/_index.md @@ -4,9 +4,15 @@ linkTitle: "RESTful API" weight: 1 --- -HugeGraph-Server provides interfaces for clients to operate on graphs based on the HTTP protocol through the HugeGraph-API. These interfaces primarily include the ability to add, delete, modify, and query metadata and graph data, perform traversal algorithms, handle variables, and perform other graph-related operations. +> ⚠️ **Version compatibility notes** +> +> - HugeGraph 1.7.0+ introduces graphspaces, and REST paths follow `/graphspaces/{graphspace}/graphs/{graph}`. +> - HugeGraph 1.5.x and earlier still rely on the legacy `/graphs/{graph}` path, and the create/clone graph APIs require `Content-Type: text/plain`; 1.7.0+ expects JSON bodies. +> - The default graphspace name is `DEFAULT`, which you can use directly if you do not need multi-tenant isolation. +> - **Note**: Before version 1.5.0, the format of ids such as group/target was similar to -69:grant. After version 1.7.0, the id and name were consistent, such as admin [HugeGraph 1.5.x RESTful API](https://github.com/apache/incubator-hugegraph-doc/tree/release-1.5.0) -Expect the doc below, you can also use `swagger-ui` to visit the `RESTful API` by `localhost:8080/swagger-ui/index.html`. [Here is an example](/docs/quickstart/hugegraph/hugegraph-server#swaggerui-example) + +Besides the documentation below, you can also open `swagger-ui` at `localhost:8080/swagger-ui/index.html` to explore the RESTful API. [Here is an example](/docs/quickstart/hugegraph/hugegraph-server#swaggerui-example) [comment]: <> (- Graph Schema) diff --git a/content/en/docs/clients/restful-api/auth.md b/content/en/docs/clients/restful-api/auth.md index 3fb187fd5..e90b84089 100644 --- a/content/en/docs/clients/restful-api/auth.md +++ b/content/en/docs/clients/restful-api/auth.md @@ -17,6 +17,7 @@ Description: User 'boss' has read permission for people in the 'graph1' graph fr ##### Interface Description: The user authentication and access control interface includes 5 categories: UserAPI, GroupAPI, TargetAPI, BelongAPI, AccessAPI. +**Note** Before 1.5.0, the format of ids such as group/target was similar to -69:grant. After 1.7.0, the id and name were consistent. Such as admin [HugeGraph 1.5 x RESTful API](https://github.com/apache/incubator-hugegraph-doc/tree/release-1.5.0) ### 10.2 User (User) API The user interface includes APIs for creating users, deleting users, modifying users, and querying user-related information. @@ -47,7 +48,7 @@ Both user_name and user_password are required. ##### Method & Url ``` -POST http://localhost:8080/graphs/hugegraph/auth/users +POST http://localhost:8080/graphspaces/DEFAULT/auth/users ``` ##### Response Status @@ -66,7 +67,7 @@ In the response message, the password is encrypted as ciphertext. "user_name": "boss", "user_creator": "admin", "user_phone": "182****9088", - "id": "-63:boss", + "id": "boss", "user_create": "2020-11-17 14:31:07.833" } ``` @@ -81,7 +82,7 @@ In the response message, the password is encrypted as ciphertext. ##### Method & Url ``` -DELETE http://localhost:8080/graphs/hugegraph/auth/users/-63:test +DELETE http://localhost:8080/graphspaces/DEFAULT/auth/users/test ``` ##### Response Status @@ -105,7 +106,7 @@ DELETE http://localhost:8080/graphs/hugegraph/auth/users/-63:test ##### Method & Url ``` -PUT http://localhost:8080/graphs/hugegraph/auth/users/-63:test +PUT http://localhost:8080/graphspaces/DEFAULT/auth/users/test ``` ##### Request Body @@ -134,7 +135,7 @@ The returned result is the entire user object including the modified content. "user_name": "test", "user_creator": "admin", "user_phone": "183****9266", - "id": "-63:test", + "id": "test", "user_create": "2020-11-12 10:27:13.601" } ``` @@ -149,7 +150,7 @@ The returned result is the entire user object including the modified content. ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/auth/users +GET http://localhost:8080/graphspaces/DEFAULT/auth/users ``` ##### Response Status @@ -168,7 +169,7 @@ GET http://localhost:8080/graphs/hugegraph/auth/users "user_update": "2020-11-11 11:41:12.254", "user_name": "admin", "user_creator": "system", - "id": "-63:admin", + "id": "admin", "user_create": "2020-11-11 11:41:12.254" } ] @@ -184,7 +185,7 @@ GET http://localhost:8080/graphs/hugegraph/auth/users ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/auth/users/-63:admin +GET http://localhost:8080/graphspaces/DEFAULT/auth/users/admin ``` ##### Response Status @@ -203,7 +204,7 @@ GET http://localhost:8080/graphs/hugegraph/auth/users/-63:admin "user_update": "2020-11-11 11:41:12.254", "user_name": "admin", "user_creator": "system", - "id": "-63:admin", + "id": "admin", "user_create": "2020-11-11 11:41:12.254" } ] @@ -215,7 +216,7 @@ GET http://localhost:8080/graphs/hugegraph/auth/users/-63:admin ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/auth/users/-63:boss/role +GET http://localhost:8080/graphspaces/DEFAULT/auth/users/boss/role ``` ##### Response Status @@ -266,7 +267,7 @@ The group interface includes APIs for creating groups, deleting groups, modifyin ##### Method & Url ``` -POST http://localhost:8080/graphs/hugegraph/auth/groups +POST http://localhost:8080/graphspaces/DEFAULT/auth/groups ``` ##### Response Status @@ -298,7 +299,7 @@ POST http://localhost:8080/graphs/hugegraph/auth/groups ##### Method & Url ``` -DELETE http://localhost:8080/graphs/hugegraph/auth/groups/-69:grant +DELETE http://localhost:8080/graphspaces/DEFAULT/auth/groups/-69:grant ``` ##### Response Status @@ -322,7 +323,7 @@ DELETE http://localhost:8080/graphs/hugegraph/auth/groups/-69:grant ##### Method & Url ``` -PUT http://localhost:8080/graphs/hugegraph/auth/groups/-69:grant +PUT http://localhost:8080/graphspaces/DEFAULT/auth/groups/-69:grant ``` ##### Request Body @@ -363,7 +364,7 @@ The returned result is the entire group object including the modified content. ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/auth/groups +GET http://localhost:8080/graphspaces/DEFAULT/auth/groups ``` ##### Response Status @@ -398,7 +399,7 @@ GET http://localhost:8080/graphs/hugegraph/auth/groups ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/auth/groups/-69:all +GET http://localhost:8080/graphspaces/DEFAULT/auth/groups/-69:all ``` ##### Response Status @@ -459,7 +460,7 @@ The resource definition means: a vertex of type 'person' with the city property ##### Method & Url ``` -POST http://localhost:8080/graphs/hugegraph/auth/targets +POST http://localhost:8080/graphspaces/DEFAULT/auth/targets ``` ##### Response Status @@ -498,7 +499,7 @@ POST http://localhost:8080/graphs/hugegraph/auth/targets ##### Method & Url ``` -DELETE http://localhost:8080/graphs/hugegraph/auth/targets/-77:gremlin +DELETE http://localhost:8080/graphspaces/DEFAULT/auth/targets/-77:gremlin ``` ##### Response Status @@ -522,7 +523,7 @@ DELETE http://localhost:8080/graphs/hugegraph/auth/targets/-77:gremlin ##### Method & Url ``` -PUT http://localhost:8080/graphs/hugegraph/auth/targets/-77:gremlin +PUT http://localhost:8080/graphspaces/DEFAULT/auth/targets/-77:gremlin ``` ##### Request Body @@ -577,7 +578,7 @@ The response contains the entire target group object, including the modified con ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/auth/targets +GET http://localhost:8080/graphspaces/DEFAULT/auth/targets ``` ##### Response Status @@ -636,7 +637,7 @@ GET http://localhost:8080/graphs/hugegraph/auth/targets ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/auth/targets/-77:grant +GET http://localhost:8080/graphspaces/DEFAULT/auth/targets/-77:grant ``` ##### Response Status @@ -683,7 +684,7 @@ The API for associating roles includes creating, deleting, modifying, and queryi ```json { - "user": "-63:boss", + "user": "boss", "group": "-69:all" } ``` @@ -692,7 +693,7 @@ The API for associating roles includes creating, deleting, modifying, and queryi ##### Method & Url ``` -POST http://localhost:8080/graphs/hugegraph/auth/belongs +POST http://localhost:8080/graphspaces/DEFAULT/auth/belongs ``` ##### Response Status @@ -708,8 +709,8 @@ POST http://localhost:8080/graphs/hugegraph/auth/belongs "belong_create": "2020-11-11 16:19:35.422", "belong_creator": "admin", "belong_update": "2020-11-11 16:19:35.422", - "id": "S-63:boss>-82>>S-69:all", - "user": "-63:boss", + "id": "Sboss>-82>>S-69:all", + "user": "boss", "group": "-69:all" } ``` @@ -723,7 +724,7 @@ POST http://localhost:8080/graphs/hugegraph/auth/belongs ##### Method & Url ``` -DELETE http://localhost:8080/graphs/hugegraph/auth/belongs/S-63:boss>-82>>S-69:grant +DELETE http://localhost:8080/graphspaces/DEFAULT/auth/belongs/Sboss>-82>>S-69:grant ``` ##### Response Status @@ -749,7 +750,7 @@ An association of roles can only be modified for its description. The `user` and ##### Method & Url ``` -PUT http://localhost:8080/graphs/hugegraph/auth/belongs/S-63:boss>-82>>S-69:grant +PUT http://localhost:8080/graphspaces/DEFAULT/auth/belongs/Sboss>-82>>S-69:grant ``` ##### Request Body @@ -774,8 +775,8 @@ The response includes the modified content as well as the entire association of "belong_create": "2020-11-12 10:40:21.720", "belong_creator": "admin", "belong_update": "2020-11-12 10:42:47.265", - "id": "S-63:boss>-82>>S-69:grant", - "user": "-63:boss", + "id": "Sboss>-82>>S-69:grant", + "user": "boss", "group": "-69:grant" } ``` @@ -790,7 +791,7 @@ The response includes the modified content as well as the entire association of ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/auth/belongs +GET http://localhost:8080/graphspaces/DEFAULT/auth/belongs ``` ##### Response Status @@ -808,8 +809,8 @@ GET http://localhost:8080/graphs/hugegraph/auth/belongs "belong_create": "2020-11-11 16:19:35.422", "belong_creator": "admin", "belong_update": "2020-11-11 16:19:35.422", - "id": "S-63:boss>-82>>S-69:all", - "user": "-63:boss", + "id": "Sboss>-82>>S-69:all", + "user": "boss", "group": "-69:all" } ] @@ -825,7 +826,7 @@ GET http://localhost:8080/graphs/hugegraph/auth/belongs ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/auth/belongs/S-63:boss>-82>>S-69:all +GET http://localhost:8080/graphspaces/DEFAULT/auth/belongs/Sboss>-82>>S-69:all ``` ##### Response Status @@ -841,8 +842,8 @@ GET http://localhost:8080/graphs/hugegraph/auth/belongs/S-63:boss>-82>>S-69:all "belong_create": "2020-11-11 16:19:35.422", "belong_creator": "admin", "belong_update": "2020-11-11 16:19:35.422", - "id": "S-63:boss>-82>>S-69:all", - "user": "-63:boss", + "id": "Sboss>-82>>S-69:all", + "user": "boss", "group": "-69:all" } ``` @@ -879,7 +880,7 @@ Access permissions: ##### Method & Url ``` -POST http://localhost:8080/graphs/hugegraph/auth/accesses +POST http://localhost:8080/graphspaces/DEFAULT/auth/accesses ``` ##### Response Status @@ -897,8 +898,8 @@ POST http://localhost:8080/graphs/hugegraph/auth/accesses "id": "S-69:all>-88>11>S-77:all", "access_update": "2020-11-11 15:54:54.008", "access_creator": "admin", - "group": "-69:all", - "target": "-77:all" + "group": "-69:all", + "target": "-77:all" } ``` @@ -911,7 +912,7 @@ POST http://localhost:8080/graphs/hugegraph/auth/accesses ##### Method & Url ``` -DELETE http://localhost:8080/graphs/hugegraph/auth/accesses/S-69:all>-88>12>S-77:all +DELETE http://localhost:8080/graphspaces/DEFAULT/auth/accesses/S-69:all>-88>12>S-77:all ``` ##### Response Status @@ -927,7 +928,8 @@ DELETE http://localhost:8080/graphs/hugegraph/auth/accesses/S-69:all>-88>12>S-77 ``` #### 10.6.3 Modify Authorization -Authorization can only be modified for its description. User group, resource, and permission cannot be modified. If you need to modify the relationship of the authorization, you can delete the original authorization relationship and create a new one. + +Authorization can only be modified for its description. User group, resource, and permission cannot be modified. If you need to modify the authorization relationship, delete the original authorization and create a new one. ##### Params @@ -936,14 +938,16 @@ Authorization can only be modified for its description. User group, resource, an ##### Method & Url ``` -PUT http://localhost:8080/graphs/hugegraph/auth/accesses/S-69:all>-88>12>S-77:all +PUT http://localhost:8080/graphspaces/DEFAULT/auth/accesses/S-69:all>-88>12>S-77:all ``` ##### Request Body + Modify access_description + ```json { - "access_description": "test" + "access_description": "test" } ``` @@ -954,17 +958,19 @@ Modify access_description ``` ##### Response Body -#### Return Result Including Modified Content of the Entire User Group Object + +The response includes the modified content as well as the entire authorization object. + ```json { - "access_description": "test", - "access_permission": "WRITE", - "access_create": "2020-11-12 10:12:03.074", - "id": "S-69:all>-88>12>S-77:all", - "access_update": "2020-11-12 10:16:18.637", - "access_creator": "admin", - "group": "-69:all", - "target": "-77:all" + "access_description": "test", + "access_permission": "WRITE", + "access_create": "2020-11-12 10:12:03.074", + "id": "S-69:all>-88>12>S-77:all", + "access_update": "2020-11-12 10:16:18.637", + "access_creator": "admin", + "group": "-69:all", + "target": "-77:all" } ``` @@ -977,7 +983,7 @@ Modify access_description ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/auth/accesses +GET http://localhost:8080/graphspaces/DEFAULT/auth/accesses ``` ##### Response Status @@ -990,17 +996,17 @@ GET http://localhost:8080/graphs/hugegraph/auth/accesses ```json { - "accesses": [ - { - "access_permission": "READ", - "access_create": "2020-11-11 15:54:54.008", - "id": "S-69:all>-88>11>S-77:all", - "access_update": "2020-11-11 15:54:54.008", - "access_creator": "admin", - "group": "-69:all", - "target": "-77:all" - } - ] + "accesses": [ + { + "access_permission": "READ", + "access_create": "2020-11-11 15:54:54.008", + "id": "S-69:all>-88>11>S-77:all", + "access_update": "2020-11-11 15:54:54.008", + "access_creator": "admin", + "group": "-69:all", + "target": "-77:all" + } + ] } ``` @@ -1013,7 +1019,7 @@ GET http://localhost:8080/graphs/hugegraph/auth/accesses ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/auth/accesses/S-69:all>-88>11>S-77:all +GET http://localhost:8080/graphspaces/DEFAULT/auth/accesses/S-69:all>-88>11>S-77:all ``` ##### Response Status @@ -1026,12 +1032,170 @@ GET http://localhost:8080/graphs/hugegraph/auth/accesses/S-69:all>-88>11>S-77:al ```json { - "access_permission": "READ", - "access_create": "2020-11-11 15:54:54.008", - "id": "S-69:all>-88>11>S-77:all", - "access_update": "2020-11-11 15:54:54.008", - "access_creator": "admin", + "access_permission": "READ", + "access_create": "2020-11-11 15:54:54.008", + "id": "S-69:all>-88>11>S-77:all", + "access_update": "2020-11-11 15:54:54.008", + "access_creator": "admin", "group": "-69:all", "target": "-77:all" } ``` + +### 10.7 Graphspace Manager (Manager) API + +> **Note**: Before using the following APIs, you need to create a graphspace first. For example, create a graphspace named `gs1` via the [Graphspace API](../graphspace). The examples below assume that `gs1` already exists. + +1. The graphspace manager API is used to grant/revoke manager roles for users at the graphspace level, and to query the roles of the current user or other users in a graphspace. Supported role types include `SPACE`, `SPACE_MEMBER`, and `ADMIN`. + +#### 10.7.1 Check whether the current login user has a specific role + +##### Params + +- type: Role type to check, optional + +##### Method & Url + +``` +GET http://localhost:8080/graphspaces/gs1/auth/managers/check?type=WRITE +``` + +##### Response Status + +```json +200 +``` + +##### Response Body + +```json +"true" +``` + +The API returns the string `true` or `false` indicating whether the current user has the given role. + +#### 10.7.2 List graphspace managers + +##### Params + +- type: Role type, optional, used to filter by role + +##### Method & Url + +``` +GET http://localhost:8080/graphspaces/gs1/auth/managers?type=SPACE +``` + +##### Response Status + +```json +200 +``` + +##### Response Body + +```json +{ + "managers": [ + { + "user": "admin", + "type": "SPACE", + "create_time": "2024-01-10 09:30:00" + } + ] +} +``` + +#### 10.7.3 Grant/create a graphspace manager + +- The following example grants user `boss` the `SPACE_MEMBER` role in graphspace `gs1`. + +##### Request Body + +```json +{ + "user": "boss", + "type": "SPACE_MEMBER" +} +``` + +##### Method & Url + +``` +POST http://localhost:8080/graphspaces/gs1/auth/managers +``` + +##### Response Status + +```json +201 +``` + +##### Response Body + +```json +{ + "user": "boss", + "type": "SPACE_MEMBER", + "manager_creator": "admin", + "manager_create": "2024-01-10 09:45:12" +} +``` + +#### 10.7.4 Revoke graphspace manager privileges + +- The following example revokes the `SPACE_MEMBER` role of user `boss` in graphspace `gs1`. + +##### Params + +- user: User ID to revoke +- type: Role type to revoke + +##### Method & Url + +``` +DELETE http://localhost:8080/graphspaces/gs1/auth/managers?user=boss&type=SPACE_MEMBER +``` + +##### Response Status + +```json +204 +``` + +##### Response Body + +```json +1 +``` + +#### 10.7.5 Query roles of a specific user in a graphspace + +##### Params + +- user: User ID + +##### Method & Url + +``` +GET http://localhost:8080/graphspaces/gs1/auth/managers/role?user=boss +``` + +##### Response Status + +```json +200 +``` + +##### Response Body + +```json +{ + "roles": { + "boss": [ + "READ", + "SPACE_MEMBER" + ] + } +} +``` diff --git a/content/en/docs/clients/restful-api/cypher.md b/content/en/docs/clients/restful-api/cypher.md index 7ce3a9727..ba120e2c7 100644 --- a/content/en/docs/clients/restful-api/cypher.md +++ b/content/en/docs/clients/restful-api/cypher.md @@ -10,29 +10,36 @@ weight: 15 ##### Method & Url -```javascript -GET /graphs/{graph}/cypher?cypher={cypher} +```http +GET /graphspaces/{graphspace}/graphs/{graph}/cypher?cypher={cypher} ``` ##### Params + +**Path parameters** + +- graphspace: Graphspace name - graph: Graph name + +**Query parameters** + - cypher: Cypher statement ##### Example -```javascript -GET http://localhost:8080/graphs/hugecypher1/cypher?cypher=match(n:person) return n.name as name order by n.name limit 1 +```http +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugecypher1/cypher?cypher=match(n:person) return n.name as name order by n.name limit 1 ``` ##### Response Status -```javascript +```json 200 ``` ##### Response Body -```javascript +```json { "requestId": "766b9f48-2f10-40d9-951a-3027d0748ab7", "status": { @@ -51,8 +58,6 @@ GET http://localhost:8080/graphs/hugecypher1/cypher?cypher=match(n:person) retur } } } - - ``` #### 9.1.2 Sending a cypher statement (POST) to HugeGraphServer for synchronous execution @@ -60,11 +65,15 @@ GET http://localhost:8080/graphs/hugecypher1/cypher?cypher=match(n:person) retur ##### Method & Url -```javascript -POST /graphs/{graph}/cypher +```http +POST /graphspaces/{graphspace}/graphs/{graph}/cypher ``` ##### Params + +**Path parameters** + +- graphspace: Graphspace name - graph: Graph name ##### Body @@ -77,8 +86,8 @@ Note: ##### Example -```javascript -POST http://localhost:8080/graphs/hugecypher1/cypher +```http +POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugecypher1/cypher ``` ###### Request Body @@ -88,12 +97,12 @@ match(n:person) return n.name as name order by n.name limit 1 ``` ##### Response Status -```javascript +```json 200 ``` ##### Response Body -```javascript +```json { "requestId": "f096bee0-e249-498f-b5a3-ea684fc84f57", "status": { @@ -112,6 +121,4 @@ match(n:person) return n.name as name order by n.name limit 1 } } } - - ``` diff --git a/content/en/docs/clients/restful-api/edge.md b/content/en/docs/clients/restful-api/edge.md index b990a54a2..aaff63967 100644 --- a/content/en/docs/clients/restful-api/edge.md +++ b/content/en/docs/clients/restful-api/edge.md @@ -76,8 +76,8 @@ g = graph.traversal() ##### Method & Url -``` -POST http://localhost:8080/graphs/hugegraph/graph/edges +```http +POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges ``` ##### Request Body @@ -138,8 +138,8 @@ POST http://localhost:8080/graphs/hugegraph/graph/edges ##### Method & Url -``` -POST http://localhost:8080/graphs/hugegraph/graph/edges/batch +```http +POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges/batch ``` ##### Request Body @@ -205,8 +205,8 @@ POST http://localhost:8080/graphs/hugegraph/graph/edges/batch ##### Method & Url -``` -PUT http://localhost:8080/graphs/hugegraph/graph/edges/S1:marko>2>>S2:lop?action=append +```http +PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges/S1:marko>2>>S2:lop?action=append ``` ##### Request Body @@ -267,8 +267,8 @@ PUT http://localhost:8080/graphs/hugegraph/graph/edges/S1:marko>2>>S2:lop?action ##### Method & Url -``` -PUT http://127.0.0.1:8080/graphs/hugegraph/graph/edges/batch +```http +PUT http://127.0.0.1:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges/batch ``` ##### Request Body @@ -368,8 +368,8 @@ PUT http://127.0.0.1:8080/graphs/hugegraph/graph/edges/batch ##### Method & Url -``` -PUT http://localhost:8080/graphs/hugegraph/graph/edges/S1:marko>2>>S2:lop?action=eliminate +```http +PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges/S1:marko>2>>S2:lop?action=eliminate ``` ##### Request Body @@ -442,8 +442,8 @@ Key-value pairs of properties consist of the property name and value in JSON for ##### Method & Url -``` -GET http://127.0.0.1:8080/graphs/hugegraph/graph/edges?vertex_id="1:marko"&label=knows&properties={"date":"P.within(\"20160111\")"} +```http +GET http://127.0.0.1:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges?vertex_id="1:marko"&label=knows&properties={"date":"P.within(\"20160111\")"} ``` ##### Response Status @@ -478,8 +478,8 @@ GET http://127.0.0.1:8080/graphs/hugegraph/graph/edges?vertex_id="1:marko"&label ##### Method & Url -``` -GET http://127.0.0.1:8080/graphs/hugegraph/graph/edges?page&limit=2 +```http +GET http://127.0.0.1:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges?page&limit=2 ``` ##### Response Status @@ -530,8 +530,8 @@ The returned body contains the page number information for the next page, `"page ##### Method & Url -``` -GET http://127.0.0.1:8080/graphs/hugegraph/graph/edges?page=EoYxOm1hcmtvgggCAIQyOmxvcAAAAAAAAAAC&limit=2 +```http +GET http://127.0.0.1:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges?page=EoYxOm1hcmtvgggCAIQyOmxvcAAAAAAAAAAC&limit=2 ``` ##### Response Status @@ -578,8 +578,8 @@ When `"page": null` is returned, it indicates that there are no more pages avail ##### Method & Url -``` -GET http://localhost:8080/graphs/hugegraph/graph/edges/S1:marko>2>>S2:lop +```http +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges/S1:marko>2>>S2:lop ``` ##### Response Status @@ -623,8 +623,8 @@ GET http://localhost:8080/graphs/hugegraph/graph/edges/S1:marko>2>>S2:lop ##### Method & Url -``` -DELETE http://localhost:8080/graphs/hugegraph/graph/edges/S1:marko>2>>S2:lop +```http +DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges/S1:marko>2>>S2:lop ``` ##### Response Status @@ -639,8 +639,8 @@ In general, specifying the Label parameter along with the ID to delete an edge w ##### Method & Url -``` -DELETE http://localhost:8080/graphs/hugegraph/graph/edges/S1:marko>1>>S1:vadas?label=knows +```http +DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges/S1:marko>1>>S1:vadas?label=knows ``` ##### Response Status diff --git a/content/en/docs/clients/restful-api/edgelabel.md b/content/en/docs/clients/restful-api/edgelabel.md index 0d4cb1dd8..4906c687f 100644 --- a/content/en/docs/clients/restful-api/edgelabel.md +++ b/content/en/docs/clients/restful-api/edgelabel.md @@ -24,7 +24,7 @@ Params Explanation ##### Method & Url ``` -POST http://localhost:8080/graphs/hugegraph/schema/edgelabels +POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/edgelabels ``` ##### Request Body @@ -133,7 +133,7 @@ Additionally, when the edge has a property called "createdTime" and you want to ##### Method & Url ``` -PUT http://localhost:8080/graphs/hugegraph/schema/edgelabels/created?action=append +PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/edgelabels/created?action=append ``` ##### Request Body @@ -186,7 +186,7 @@ PUT http://localhost:8080/graphs/hugegraph/schema/edgelabels/created?action=appe ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/schema/edgelabels +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/edgelabels ``` ##### Response Status @@ -248,7 +248,7 @@ GET http://localhost:8080/graphs/hugegraph/schema/edgelabels ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/schema/edgelabels/created +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/edgelabels/created ``` ##### Response Status @@ -291,7 +291,7 @@ Deleting an EdgeLabel will result in the deletion of corresponding edges and rel ##### Method & Url ``` -DELETE http://localhost:8080/graphs/hugegraph/schema/edgelabels/created +DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/edgelabels/created ``` ##### Response Status @@ -310,4 +310,4 @@ DELETE http://localhost:8080/graphs/hugegraph/schema/edgelabels/created Note: -> You can query the execution status of an asynchronous task by using `GET http://localhost:8080/graphs/hugegraph/tasks/1` (where "1" is the task_id). For more information, refer to the [Asynchronous Task RESTful API](../task). +> You can query the execution status of an asynchronous task by using `GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/1` (where "1" is the task_id). For more information, refer to the [Asynchronous Task RESTful API](../task). diff --git a/content/en/docs/clients/restful-api/graphs.md b/content/en/docs/clients/restful-api/graphs.md index 3ce4bb5f6..913d8ae2a 100644 --- a/content/en/docs/clients/restful-api/graphs.md +++ b/content/en/docs/clients/restful-api/graphs.md @@ -6,12 +6,20 @@ weight: 12 ### 6.1 Graphs -#### 6.1.1 List all graphs +**Important Reminder**: Since HugeGraph 1.7.0, dynamic graph creation must enable authentication mode. For non-authentication mode, please refer to [Graph Configuration File](https://hugegraph.apache.org/docs/config/config-guide/#4-hugegraphproperties) to statically create graphs through configuration files. + +#### 6.1.1 List all graphs in the graphspace + +##### Params + +**Path parameters** + +- graphspace: Graphspace name ##### Method & Url ``` -GET http://localhost:8080/graphs +GET http://localhost:8080/graphspaces/DEFAULT/graphs ``` ##### Response Status @@ -33,10 +41,17 @@ GET http://localhost:8080/graphs #### 6.1.2 Get details of the graph +##### Params + +**Path parameters** + +- graphspace: Graphspace name +- graph: Graph name + ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph ``` ##### Response Status @@ -54,22 +69,25 @@ GET http://localhost:8080/graphs/hugegraph } ``` -#### 6.1.3 Clear all data of a graph, include: schema, vertex, edge and index .etc.,**This operation - -requires administrator privileges** +#### 6.1.3 Clear all data of a graph, include: schema, vertex, edge and index, **This operation requires administrator privileges** ##### Params -Since emptying the graph is a dangerous operation, we have added parameters for confirmation to the -API to -avoid false calls by users: +**Path parameters** + +- graphspace: Graphspace name +- graph: Graph name + +**Query parameters** + +Since emptying the graph is a dangerous operation, we have added parameters for confirmation to the API to avoid false calls by users: - confirm_message: default by `I'm sure to delete all data` ##### Method & Url ``` -DELETE http://localhost:8080/graphs/hugegraph/clear?confirm_message=I%27m+sure+to+delete+all+data +DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/clear?confirm_message=I%27m+sure+to+delete+all+data ``` ##### Response Status @@ -78,31 +96,38 @@ DELETE http://localhost:8080/graphs/hugegraph/clear?confirm_message=I%27m+sure+t 204 ``` -#### 6.1.4 Clone graph,**this operation requires administrator privileges** +#### 6.1.4 Clone graph, **this operation requires administrator privileges** ##### Params -- clone_graph_name: name of an existed graph. - To clone from an existing graph, the user can choose to transfer the configuration file, - which will replace the configuration in the existing graph +**Path parameters** + +- graphspace: Graphspace name +- graph: Name of the new graph to create + +**Query parameters** + +- clone_graph_name: name of an existed graph. To clone from an existing graph, the user can choose to transfer the configuration file, which will replace the configuration in the existing graph ##### Method & Url ``` -POST http://localhost:8080/graphs/hugegraph_clone?clone_graph_name=hugegraph +POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph_clone?clone_graph_name=hugegraph ``` ##### Request Body [Optional] -Clone a `non-auth` mode graph: (Must set body `Context-Type=text/plain`) +Clone a `non-auth` mode graph (set `Content-Type: application/json`) -```properties -gremlin.graph=org.apache.hugegraph.HugeFactory -backend=rocksdb -serializer=binary -store=hugegraph_clone -rocksdb.data_path=./rks-data-xx -rocksdb.wal_path=./rks-data-xx +```json +{ + "gremlin.graph": "org.apache.hugegraph.HugeFactory", + "backend": "rocksdb", + "serializer": "binary", + "store": "hugegraph", + "rocksdb.data_path": "./rks-data-xx", + "rocksdb.wal_path": "./rks-data-xx" +} ``` > Note: @@ -124,25 +149,34 @@ rocksdb.wal_path=./rks-data-xx } ``` -#### 6.1.5 Create graph,**this operation requires administrator privileges** +#### 6.1.5 Create graph, **this operation requires administrator privileges** + +##### Params + +**Path parameters** + +- graphspace: Graphspace name +- graph: Graph name ##### Method & Url ``` -POST http://localhost:8080/graphs/hugegraph2 +POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph2 ``` ##### Request Body -create a non-auth graph: (Must set body `Context-Type=text/plain`) +Create a non-auth graph (set `Content-Type: application/json`) -```properties -gremlin.graph=org.apache.hugegraph.HugeFactory -backend=rocksdb -serializer=binary -store=hugegraph2 -rocksdb.data_path=./rks-data-xx -rocksdb.wal_path=./rks-data-xx +```json +{ + "gremlin.graph": "org.apache.hugegraph.HugeFactory", + "backend": "rocksdb", + "serializer": "binary", + "store": "hugegraph2", + "rocksdb.data_path": "./rks-data-xx", + "rocksdb.wal_path": "./rks-data-xx" +} ``` > Note: @@ -164,20 +198,25 @@ rocksdb.wal_path=./rks-data-xx } ``` -#### 6.1.6 Delete graph and it's data +#### 6.1.6 Delete graph and its data ##### Params -Since deleting a graph is a dangerous operation, we have added parameters for confirmation to the -API to -avoid false calls by users: +**Path parameters** + +- graphspace: Graphspace name +- graph: Graph name + +**Query parameters** + +Since deleting a graph is a dangerous operation, we have added parameters for confirmation to the API to avoid false calls by users: - confirm_message: default by `I'm sure to drop the graph` ##### Method & Url ``` -DELETE http://localhost:8080/graphs/hugegraph_clone?confirm_message=I%27m%20sure%20to%20drop%20the%20graph +DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph_clone?confirm_message=I%27m%20sure%20to%20drop%20the%20graph ``` ##### Response Status @@ -186,14 +225,23 @@ DELETE http://localhost:8080/graphs/hugegraph_clone?confirm_message=I%27m%20sure 204 ``` +> Note: For HugeGraph 1.5.0 and earlier versions, if you need to create or drop a graph, please still use the legacy `text/plain` (properties) style request body instead of JSON. + ### 6.2 Conf -#### 6.2.1 Get configuration for a graph,**This operation requires administrator privileges** +#### 6.2.1 Get configuration for a graph, **This operation requires administrator privileges** + +##### Params + +**Path parameters** + +- graphspace: Graphspace name +- graph: Graph name ##### Method & Url ```javascript -GET http://localhost:8080/graphs/hugegraph/conf +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/conf ``` ##### Response Status @@ -247,12 +295,19 @@ Under normal circumstances, the graph mode is None. When you need to restore the you need to temporarily modify the graph mode to Restoring or Merging as needed. When you complete the restore, change the graph mode to None. -#### 6.3.1 Get graph mode. +#### 6.3.1 Get graph mode + +##### Params + +**Path parameters** + +- graphspace: Graphspace name +- graph: Graph name ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/mode +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/mode ``` ##### Response Status @@ -273,10 +328,17 @@ GET http://localhost:8080/graphs/hugegraph/mode #### 6.3.2 Modify graph mode. **This operation requires administrator privileges** +##### Params + +**Path parameters** + +- graphspace: Graphspace name +- graph: Graph name + ##### Method & Url ``` -PUT http://localhost:8080/graphs/hugegraph/mode +PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/mode ``` ##### Request Body @@ -301,16 +363,19 @@ PUT http://localhost:8080/graphs/hugegraph/mode } ``` -#### 6.3.3 Get graph's read mode. +#### 6.3.3 Get graph's read mode ##### Params -- name: name of a graph +**Path parameters** + +- graphspace: Graphspace name +- graph: Graph name ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/graph_read_mode +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph_read_mode ``` ##### Response Status @@ -331,12 +396,15 @@ GET http://localhost:8080/graphs/hugegraph/graph_read_mode ##### Params -- name: name of a graph +**Path parameters** + +- graphspace: Graphspace name +- graph: Graph name ##### Method & Url ``` -PUT http://localhost:8080/graphs/hugegraph/graph_read_mode +PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph_read_mode ``` ##### Request Body @@ -367,12 +435,15 @@ PUT http://localhost:8080/graphs/hugegraph/graph_read_mode ##### Params -- name: name of a graph +**Path parameters** + +- graphspace: Graphspace name +- graph: Graph name ##### Method & Url ``` -PUT http://localhost:8080/graphs/hugegraph/snapshot_create +PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/snapshot_create ``` ##### Response Status @@ -393,12 +464,15 @@ PUT http://localhost:8080/graphs/hugegraph/snapshot_create ##### Params -- name: name of a graph +**Path parameters** + +- graphspace: Graphspace name +- graph: Graph name ##### Method & Url ``` -PUT http://localhost:8080/graphs/hugegraph/snapshot_resume +PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/snapshot_resume ``` ##### Response Status @@ -417,16 +491,19 @@ PUT http://localhost:8080/graphs/hugegraph/snapshot_resume ### 6.5 Compact -#### 6.5.1 Manually compact graph,**This operation requires administrator privileges** +#### 6.5.1 Manually compact graph, **This operation requires administrator privileges** ##### Params -- name: name of a graph +**Path parameters** + +- graphspace: Graphspace name +- graph: Graph name ##### Method & Url ``` -PUT http://localhost:8080/graphs/hugegraph/compact +PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/compact ``` ##### Response Status diff --git a/content/en/docs/clients/restful-api/graphspace.md b/content/en/docs/clients/restful-api/graphspace.md new file mode 100644 index 000000000..15eb1a91b --- /dev/null +++ b/content/en/docs/clients/restful-api/graphspace.md @@ -0,0 +1,281 @@ +--- +title: "Graphspace API" +linkTitle: "Graphspace" +weight: 1 +--- + +### 2.0 Graphspace + +HugeGraph implements multi-tenancy through graph spaces, which isolate compute/storage resources per tenant. + +**Prerequisites** + +1. Graphspace currently only works in HStore mode. +2. In non-HStore mode you can only use the default graphspace `DEFAULT`; creating/deleting/updating other graphspaces is not supported. +3. Set `usePD=true` in `rest-server.properties` and `backend=hstore` in `hugegraph.properties`. +4. Graphspace enables strict authentication by default (default credential: `admin:pa`). Change the password immediately to avoid unauthorized access. + +#### 2.0.1 Create a graphspace + +##### Method & Url + +``` +POST http://localhost:8080/graphspaces +``` + +##### Request Body + +Note: CPU/memory and Kubernetes-related capabilities are not publicly available yet. + +| Name | Required | Type | Default | Range/Note | Description | +|------------------------------|----------|---------|---------|--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------| +| name | Yes | String | | Lowercase letters, digits, underscore; must start with a letter; max length 48 | Graphspace name | +| description | Yes | String | | | Description | +| cpu_limit | Yes | Int | | > 0 | CPU cores for the graphspace | +| memory_limit | Yes | Int | | > 0 (GB) | Memory quota in GB | +| storage_limit | Yes | Int | | > 0 | Maximum disk usage | +| compute_cpu_limit | No | Int | 0 | >= 0 | Extra HugeGraph-Computer CPU cores; falls back to `cpu_limit` if unset or 0 | +| compute_memory_limit | No | Int | 0 | >= 0 | Extra HugeGraph-Computer memory in GB; falls back to `memory_limit` if unset or 0 | +| oltp_namespace | Yes | String | | | Kubernetes namespace for OLTP HugeGraph-Server | +| olap_namespace | Yes | String | | Resources are merged when identical to `oltp_namespace` | Kubernetes namespace for OLAP / HugeGraph-Computer | +| storage_namespace | Yes | String | | | Kubernetes namespace for HugeGraph-Store | +| operator_image_path | No | String | | | HugeGraph-Computer operator image registry | +| internal_algorithm_image_url | No | String | | | HugeGraph-Computer algorithm image registry | +| max_graph_number | Yes | Int | | > 0 | Maximum number of graphs that can be created inside the graphspace | +| max_role_number | Yes | Int | | > 0 | Maximum number of roles that can be created inside the graphspace | +| auth | No | Boolean | false | true / false | Whether to enable authentication for the graphspace | +| configs | No | Map | | | Additional configuration | + +```json +{ + "name": "gs1", + "description": "1st graph space", + "max_graph_number": 100, + "cpu_limit": 1000, + "memory_limit": 8192, + "storage_limit": 1000000, + "max_role_number": 10, + "auth": true, + "configs": {} +} +``` + +##### Response Status + +```json +201 +``` + +##### Response Body + +```json +{ + "name": "gs1", + "description": "1st graph space", + "cpu_limit": 1000, + "memory_limit": 8192, + "storage_limit": 1000000, + "compute_cpu_limit": 0, + "compute_memory_limit": 0, + "oltp_namespace": "hugegraph-server", + "olap_namespace": "hugegraph-server", + "storage_namespace": "hugegraph-server", + "operator_image_path": "127.0.0.1/hugegraph-registry/hugegraph-computer-operator:3.1.1", + "internal_algorithm_image_url": "127.0.0.1/hugegraph-registry/hugegraph-computer-algorithm:3.1.1", + "max_graph_number": 100, + "max_role_number": 10, + "cpu_used": 0, + "memory_used": 0, + "storage_used": 0, + "graph_number_used": 0, + "role_number_used": 0, + "auth": true +} +``` + +#### 2.0.2 List all graphspaces + +##### Method & Url + +``` +GET http://localhost:8080/graphspaces +``` + +##### Response Status + +```json +200 +``` + +##### Response Body + +```json +{ + "graphSpaces": [ + "gs1", + "DEFAULT" + ] +} +``` + +#### 2.0.3 Get graphspace details + +##### Params + +**Path parameters** + +- graphspace: Graphspace name + +##### Method & Url + +``` +GET http://localhost:8080/graphspaces/gs1 +``` + +##### Response Status + +```json +200 +``` + +##### Response Body + +```json +{ + "name": "gs1", + "description": "1st graph space", + "cpu_limit": 1000, + "memory_limit": 8192, + "storage_limit": 1000000, + "oltp_namespace": "hugegraph-server", + "olap_namespace": "hugegraph-server", + "storage_namespace": "hugegraph-server", + "operator_image_path": "127.0.0.1/hugegraph-registry/hugegraph-computer-operator:3.1.1", + "internal_algorithm_image_url": "127.0.0.1/hugegraph-registry/hugegraph-computer-algorithm:3.1.1", + "compute_cpu_limit": 0, + "compute_memory_limit": 0, + "max_graph_number": 100, + "max_role_number": 10, + "cpu_used": 0, + "memory_used": 0, + "storage_used": 0, + "graph_number_used": 0, + "role_number_used": 0, + "auth": true +} +``` + +#### 2.0.4 Update a graphspace + +> `auth` cannot be changed once a graphspace is created. + +##### Params + +**Path parameter** + +- graphspace: Graphspace name + +**Request parameters** + +- action: Must be `"update"` +- update: Container for the actual fields to update (see table below) + +| Name | Required | Type | Range/Note | Description | +|------------------------------|----------|--------|---------------------------------------------------------|-----------------------------------------------------------------------------------| +| name | Yes | String | | Graphspace name | +| description | Yes | String | | Description | +| cpu_limit | Yes | Int | > 0 | CPU cores for OLTP HugeGraph-Server | +| memory_limit | Yes | Int | > 0 (GB) | Memory quota (GB) for OLTP HugeGraph-Server | +| storage_limit | Yes | Int | > 0 | Maximum disk usage | +| compute_cpu_limit | No | Int | >= 0 | Extra HugeGraph-Computer CPU cores; falls back to `cpu_limit` if unset or 0 | +| compute_memory_limit | No | Int | >= 0 | Extra HugeGraph-Computer memory in GB; falls back to `memory_limit` if unset or 0 | +| oltp_namespace | Yes | String | | Kubernetes namespace for OLTP HugeGraph-Server | +| olap_namespace | Yes | String | Resources are merged when identical to `oltp_namespace` | Kubernetes namespace for OLAP | +| storage_namespace | Yes | String | | Kubernetes namespace for HugeGraph-Store | +| operator_image_path | No | String | | HugeGraph-Computer operator image registry | +| internal_algorithm_image_url | No | String | | HugeGraph-Computer algorithm image registry | +| max_graph_number | Yes | Int | > 0 | Maximum number of graphs | +| max_role_number | Yes | Int | > 0 | Maximum number of roles | + +##### Method & Url + +``` +PUT http://localhost:8080/graphspaces/gs1 +``` + +##### Request Body + +```json +{ + "action": "update", + "update": { + "name": "gs1", + "description": "1st graph space", + "cpu_limit": 2000, + "memory_limit": 40960, + "storage_limit": 2048, + "oltp_namespace": "hugegraph-server", + "olap_namespace": "hugegraph-server", + "operator_image_path": "127.0.0.1/hugegraph-registry/hugegraph-computer-operator:3.1.1", + "internal_algorithm_image_url": "127.0.0.1/hugegraph-registry/hugegraph-computer-algorithm:3.1.1", + "max_graph_number": 1000, + "max_role_number": 100 + } +} +``` + +##### Response Status + +```json +200 +``` + +##### Response Body + +```json +{ + "name": "gs1", + "description": "1st graph space", + "cpu_limit": 2000, + "memory_limit": 40960, + "storage_limit": 2048, + "oltp_namespace": "hugegraph-server", + "olap_namespace": "hugegraph-server", + "storage_namespace": "hugegraph-server", + "operator_image_path": "127.0.0.1/hugegraph-registry/hugegraph-computer-operator:3.1.1", + "internal_algorithm_image_url": "127.0.0.1/hugegraph-registry/hugegraph-computer-algorithm:3.1.1", + "compute_cpu_limit": 0, + "compute_memory_limit": 0, + "max_graph_number": 1000, + "max_role_number": 100, + "cpu_used": 0, + "memory_used": 0, + "storage_used": 0, + "graph_number_used": 0, + "role_number_used": 0, + "auth": true +} +``` + +#### 2.0.5 Delete a graphspace + +##### Params + +**Path parameter** + +- graphspace: Graphspace name + +##### Method & Url + +``` +DELETE http://localhost:8080/graphspaces/gs1 +``` + +##### Response Status + +```json +204 +``` + +> Warning: deleting a graphspace releases all resources that belong to it. + diff --git a/content/en/docs/clients/restful-api/gremlin.md b/content/en/docs/clients/restful-api/gremlin.md index 0529a9ce4..f78ad082c 100644 --- a/content/en/docs/clients/restful-api/gremlin.md +++ b/content/en/docs/clients/restful-api/gremlin.md @@ -188,7 +188,7 @@ Note: ##### Method & Url ``` -POST http://localhost:8080/graphs/hugegraph/jobs/gremlin +POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/jobs/gremlin ``` **Querying vertices** @@ -224,7 +224,7 @@ Note: Note: -> You can query the execution status of an asynchronous task by using `GET http://localhost:8080/graphs/hugegraph/tasks/1` (where "1" is the task_id). For more information, refer to the [Asynchronous Task RESTful API](../task). +> You can query the execution status of an asynchronous task by using `GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/1` (where "1" is the task_id). For more information, refer to the [Asynchronous Task RESTful API](../task). **Querying edges** @@ -255,4 +255,4 @@ Note: Note: -> You can query the execution status of an asynchronous task by using `GET http://localhost:8080/graphs/hugegraph/tasks/2` (where "2" is the task_id). For more information, refer to the [Asynchronous Task RESTful API](../task). +> You can query the execution status of an asynchronous task by using `GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/2` (where "2" is the task_id). For more information, refer to the [Asynchronous Task RESTful API](../task). diff --git a/content/en/docs/clients/restful-api/indexlabel.md b/content/en/docs/clients/restful-api/indexlabel.md index f98f39b7a..74320d37d 100644 --- a/content/en/docs/clients/restful-api/indexlabel.md +++ b/content/en/docs/clients/restful-api/indexlabel.md @@ -13,7 +13,7 @@ Assuming PropertyKeys from version 1.1.3, VertexLabels from version 1.2.3, and E ##### Method & Url ``` -POST http://localhost:8080/graphs/hugegraph/schema/indexlabels +POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/indexlabels ``` ##### Request Body @@ -59,7 +59,7 @@ POST http://localhost:8080/graphs/hugegraph/schema/indexlabels ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/schema/indexlabels +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/indexlabels ``` ##### Response Status @@ -123,7 +123,7 @@ GET http://localhost:8080/graphs/hugegraph/schema/indexlabels ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/schema/indexlabels/personByCity +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/indexlabels/personByCity ``` ##### Response Status @@ -154,7 +154,7 @@ Deleting an IndexLabel will result in the deletion of related index data. This o ##### Method & Url ``` -DELETE http://localhost:8080/graphs/hugegraph/schema/indexlabels/personByCity +DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/indexlabels/personByCity ``` ##### Response Status @@ -173,4 +173,4 @@ DELETE http://localhost:8080/graphs/hugegraph/schema/indexlabels/personByCity Note: -> You can query the execution status of an asynchronous task by using `GET http://localhost:8080/graphs/hugegraph/tasks/1` (where "1" is the task_id). For more information, refer to the [Asynchronous Task RESTful API](../task). +> You can query the execution status of an asynchronous task by using `GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/1` (where "1" is the task_id). For more information, refer to the [Asynchronous Task RESTful API](../task). diff --git a/content/en/docs/clients/restful-api/propertykey.md b/content/en/docs/clients/restful-api/propertykey.md index 71d503963..90c76414c 100644 --- a/content/en/docs/clients/restful-api/propertykey.md +++ b/content/en/docs/clients/restful-api/propertykey.md @@ -23,7 +23,7 @@ Request Body Field Description: ##### Method & Url ``` -POST http://localhost:8080/graphs/hugegraph/schema/propertykeys +POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/propertykeys ``` ##### Request Body @@ -72,7 +72,7 @@ POST http://localhost:8080/graphs/hugegraph/schema/propertykeys ##### Method & Url ``` -PUT http://localhost:8080/graphs/hugegraph/schema/propertykeys/age?action=append +PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/propertykeys/age?action=append ``` ##### Request Body @@ -121,7 +121,7 @@ PUT http://localhost:8080/graphs/hugegraph/schema/propertykeys/age?action=append ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/schema/propertykeys +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/propertykeys ``` ##### Response Status @@ -200,7 +200,7 @@ GET http://localhost:8080/graphs/hugegraph/schema/propertykeys ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/schema/propertykeys/age +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/propertykeys/age ``` Where `age` is the name of the PropertyKey to be retrieved. @@ -236,7 +236,7 @@ Where `age` is the name of the PropertyKey to be retrieved. ##### Method & Url ``` -DELETE http://localhost:8080/graphs/hugegraph/schema/propertykeys/age +DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/propertykeys/age ``` Where `age` is the name of the PropertyKey to be deleted. diff --git a/content/en/docs/clients/restful-api/rank.md b/content/en/docs/clients/restful-api/rank.md index 6a7525fd8..e1dd71a4c 100644 --- a/content/en/docs/clients/restful-api/rank.md +++ b/content/en/docs/clients/restful-api/rank.md @@ -162,7 +162,7 @@ A random walk based PersonalRank algorithm should be likes this: ###### Method & Url ``` -POST http://localhost:8080/graphs/hugegraph/traversers/personalrank +POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/traversers/personalrank ``` ###### Request Body @@ -318,7 +318,7 @@ In graph words: to go out from the starting point, get the probability of going ###### Method & Url ``` -POST http://localhost:8080/graphs/hugegraph/traversers/neighborrank +POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/traversers/neighborrank ``` ###### Request Body diff --git a/content/en/docs/clients/restful-api/rebuild.md b/content/en/docs/clients/restful-api/rebuild.md index cc9fb64e9..b2dbaf6f3 100644 --- a/content/en/docs/clients/restful-api/rebuild.md +++ b/content/en/docs/clients/restful-api/rebuild.md @@ -11,7 +11,7 @@ weight: 6 ##### Method & Url ``` -PUT http://localhost:8080/graphs/hugegraph/jobs/rebuild/indexlabels/personByCity +PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/jobs/rebuild/indexlabels/personByCity ``` ##### Response Status @@ -29,14 +29,14 @@ PUT http://localhost:8080/graphs/hugegraph/jobs/rebuild/indexlabels/personByCity ``` Note: -> You can get the asynchronous job status by `GET http://localhost:8080/graphs/hugegraph/tasks/${task_id}` (the task_id here should be 1). See More [AsyncJob RESTfull API](../task) +> You can get the asynchronous job status by `GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/${task_id}` (the task_id here should be 1). See More [AsyncJob RESTfull API](../task) #### 1.6.2 Rebulid all Indexs of VertexLabel ##### Method & Url ``` -PUT http://localhost:8080/graphs/hugegraph/jobs/rebuild/vertexlabels/person +PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/jobs/rebuild/vertexlabels/person ``` ##### Response Status @@ -55,14 +55,14 @@ PUT http://localhost:8080/graphs/hugegraph/jobs/rebuild/vertexlabels/person Note: -> You can get the asynchronous job status by `GET http://localhost:8080/graphs/hugegraph/tasks/${task_id}` (the task_id here should be 2). See More [AsyncJob RESTfull API](../task) +> You can get the asynchronous job status by `GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/${task_id}` (the task_id here should be 2). See More [AsyncJob RESTfull API](../task) #### 1.6.3 Rebulid all Indexs of EdgeLabel ##### Method & Url ``` -PUT http://localhost:8080/graphs/hugegraph/jobs/rebuild/edgelabels/created +PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/jobs/rebuild/edgelabels/created ``` ##### Response Status @@ -81,4 +81,4 @@ PUT http://localhost:8080/graphs/hugegraph/jobs/rebuild/edgelabels/created Note: -> You can get the asynchronous job status by `GET http://localhost:8080/graphs/hugegraph/tasks/${task_id}` (the task_id here should be 3). See More [AsyncJob RESTfull API](../task) \ No newline at end of file +> You can get the asynchronous job status by `GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/${task_id}` (the task_id here should be 3). See More [AsyncJob RESTfull API](../task) \ No newline at end of file diff --git a/content/en/docs/clients/restful-api/schema.md b/content/en/docs/clients/restful-api/schema.md index d549fac70..6364cd3e4 100644 --- a/content/en/docs/clients/restful-api/schema.md +++ b/content/en/docs/clients/restful-api/schema.md @@ -11,9 +11,9 @@ HugeGraph provides a single interface to get all Schema information of a graph, ##### Method & Url ``` -GET http://localhost:8080/graphs/{graph_name}/schema +GET http://localhost:8080/graphspaces/{graphspace}/graphs/{graph_name}/schema -e.g: GET http://localhost:8080/graphs/hugegraph/schema +e.g: GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema ``` ##### Response Status diff --git a/content/en/docs/clients/restful-api/task.md b/content/en/docs/clients/restful-api/task.md index d1852f2cb..18f87d560 100644 --- a/content/en/docs/clients/restful-api/task.md +++ b/content/en/docs/clients/restful-api/task.md @@ -16,7 +16,7 @@ weight: 13 ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/tasks?status=success +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks?status=success ``` ##### Response Status @@ -50,7 +50,7 @@ GET http://localhost:8080/graphs/hugegraph/tasks?status=success ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/tasks/2 +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/2 ``` ##### Response Status @@ -82,7 +82,7 @@ GET http://localhost:8080/graphs/hugegraph/tasks/2 ##### Method & Url ``` -DELETE http://localhost:8080/graphs/hugegraph/tasks/2 +DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/2 ``` ##### Response Status @@ -110,7 +110,7 @@ If you already created an async task via [Gremlin API](/docs/clients/restful-api ##### Method & Url ``` -PUT http://localhost:8080/graphs/hugegraph/tasks/2?action=cancel +PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/2?action=cancel ``` > cancel it in 10s. if more than 10s, the task may already be finished, then can't be cancelled. diff --git a/content/en/docs/clients/restful-api/traverser.md b/content/en/docs/clients/restful-api/traverser.md index f6b21ee93..681166132 100644 --- a/content/en/docs/clients/restful-api/traverser.md +++ b/content/en/docs/clients/restful-api/traverser.md @@ -2414,7 +2414,7 @@ Queries a batch of "fusiform similar vertices" based on specified conditions. Wh ###### Method & Url ``` -POST http://localhost:8080/graphs/hugegraph/traversers/fusiformsimilarity +POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/traversers/fusiformsimilarity ``` ###### Request Body @@ -2521,7 +2521,7 @@ Used to query vertices that have high similarity with a group of vertices. For e ###### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/traversers/vertices?ids="1:marko"&ids="2:lop" +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/traversers/vertices?ids="1:marko"&ids="2:lop" ``` ###### Response Status @@ -2600,7 +2600,7 @@ Obtain vertex shard information by specifying the shard size `split_size` (can b ###### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/traversers/vertices/shards?split_size=67108864 +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/traversers/vertices/shards?split_size=67108864 ``` ###### Response Status @@ -2653,7 +2653,7 @@ Retrieve vertices in batches based on the specified shard information (refer to ###### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/traversers/vertices/scan?start=0&end=4294967295 +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/traversers/vertices/scan?start=0&end=4294967295 ``` ###### Response Status @@ -2837,7 +2837,7 @@ GET http://localhost:8080/graphs/hugegraph/traversers/vertices/scan?start=0&end= ###### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/traversers/edges?ids="S1:josh>1>>S2:lop"&ids="S1:josh>1>>S2:ripple" +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/traversers/edges?ids="S1:josh>1>>S2:lop"&ids="S1:josh>1>>S2:ripple" ``` ###### Response Status @@ -2892,7 +2892,7 @@ Retrieve shard information for edges by specifying the shard size (`split_size`) ###### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/traversers/edges/shards?split_size=4294967295 +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/traversers/edges/shards?split_size=4294967295 ``` ###### Response Status @@ -2949,7 +2949,7 @@ Batch retrieve edges by specifying shard information (refer to section 3.2.22.2 ###### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/traversers/edges/scan?start=0&end=3221225469 +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/traversers/edges/scan?start=0&end=3221225469 ``` ###### Response Status diff --git a/content/en/docs/clients/restful-api/variable.md b/content/en/docs/clients/restful-api/variable.md index 572bab32a..151498771 100644 --- a/content/en/docs/clients/restful-api/variable.md +++ b/content/en/docs/clients/restful-api/variable.md @@ -13,7 +13,7 @@ Variables can be used to store data about the entire graph. The data is accessed ##### Method & Url ``` -PUT http://localhost:8080/graphs/hugegraph/variables/name +PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/variables/name ``` ##### Request Body @@ -43,7 +43,7 @@ PUT http://localhost:8080/graphs/hugegraph/variables/name ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/variables +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/variables ``` ##### Response Status @@ -65,7 +65,7 @@ GET http://localhost:8080/graphs/hugegraph/variables ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/variables/name +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/variables/name ``` ##### Response Status @@ -87,7 +87,7 @@ GET http://localhost:8080/graphs/hugegraph/variables/name ##### Method & Url ``` -DELETE http://localhost:8080/graphs/hugegraph/variables/name +DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/variables/name ``` ##### Response Status diff --git a/content/en/docs/clients/restful-api/vertex.md b/content/en/docs/clients/restful-api/vertex.md index 78e8f4c5f..d016cb146 100644 --- a/content/en/docs/clients/restful-api/vertex.md +++ b/content/en/docs/clients/restful-api/vertex.md @@ -45,7 +45,7 @@ schema.indexLabel("personByAge").onV("person").by("age").range().ifNotExist().cr ##### Method & Url ``` -POST http://localhost:8080/graphs/hugegraph/graph/vertices +POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices ``` ##### Request Body @@ -85,7 +85,7 @@ POST http://localhost:8080/graphs/hugegraph/graph/vertices ##### Method & Url ``` -POST http://localhost:8080/graphs/hugegraph/graph/vertices/batch +POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices/batch ``` ##### Request Body @@ -130,7 +130,7 @@ POST http://localhost:8080/graphs/hugegraph/graph/vertices/batch ##### Method & Url ``` -PUT http://127.0.0.1:8080/graphs/hugegraph/graph/vertices/"1:marko"?action=append +PUT http://127.0.0.1:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices/"1:marko"?action=append ``` ##### Request Body @@ -220,13 +220,13 @@ Assuming the original vertex and properties are: Add vertices with the following command: ```shell -curl -H "Content-Type: application/json" -d '[{"label":"person","properties":{"name":"josh","age":32,"city":"Beijing","weight":0.1,"hobby":["reading","football"]}},{"label":"software","properties":{"name":"lop","lang":"java","price":328}}]' http:///127.0.0.1:8080/graphs/hugegraph/graph/vertices/batch +curl -H "Content-Type: application/json" -d '[{"label":"person","properties":{"name":"josh","age":32,"city":"Beijing","weight":0.1,"hobby":["reading","football"]}},{"label":"software","properties":{"name":"lop","lang":"java","price":328}}]' http://127.0.0.1:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices/batch ``` ##### Method & Url ``` -PUT http://127.0.0.1:8080/graphs/hugegraph/graph/vertices/batch +PUT http://127.0.0.1:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices/batch ``` ##### Request Body @@ -324,7 +324,7 @@ The usage of other update strategies can be inferred in a similar manner and wil ##### Method & Url ``` -PUT http://127.0.0.1:8080/graphs/hugegraph/graph/vertices/"1:marko"?action=eliminate +PUT http://127.0.0.1:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices/"1:marko"?action=eliminate ``` ##### Request Body @@ -391,7 +391,7 @@ Property key-value pairs consist of the property name and value in JSON format. ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/graph/vertices?label=person&properties={"age":29}&limit=1 +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices?label=person&properties={"age":29}&limit=1 ``` ##### Response Status @@ -423,13 +423,13 @@ GET http://localhost:8080/graphs/hugegraph/graph/vertices?label=person&propertie Add vertices with the following command: ```shell -curl -H "Content-Type: application/json" -d '[{"label":"person","properties":{"name":"peter","age":29,"city":"Shanghai"}},{"label":"person","properties":{"name":"vadas","age":27,"city":"Hongkong"}}]' http://localhost:8080/graphs/hugegraph/graph/vertices/batch +curl -H "Content-Type: application/json" -d '[{"label":"person","properties":{"name":"peter","age":29,"city":"Shanghai"}},{"label":"person","properties":{"name":"vadas","age":27,"city":"Hongkong"}}]' http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices/batch ``` ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/graph/vertices?page&limit=3 +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices?page&limit=3 ``` ##### Response Status @@ -490,7 +490,7 @@ The returned `body` contains information about the page number of the next `page ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/graph/vertices?page=CIYxOnBldGVyAAAAAAAAAAM=&limit=3 +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices?page=CIYxOnBldGVyAAAAAAAAAAM=&limit=3 ``` ##### Response Status @@ -546,7 +546,7 @@ At this point, `"page": null` indicates that there are no more pages available. ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/graph/vertices/"1:marko" +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices/"1:marko" ``` ##### Response Status @@ -580,7 +580,7 @@ GET http://localhost:8080/graphs/hugegraph/graph/vertices/"1:marko" ##### Method & Url ``` -DELETE http://localhost:8080/graphs/hugegraph/graph/vertices/"1:marko" +DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices/"1:marko" ``` ##### Response Status @@ -596,7 +596,7 @@ When deleting a vertex by specifying both the Label parameter and the ID, it gen ##### Method & Url ``` -DELETE http://localhost:8080/graphs/hugegraph/graph/vertices/"1:marko"?label=person +DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices/"1:marko"?label=person ``` ##### Response Status diff --git a/content/en/docs/clients/restful-api/vertexlabel.md b/content/en/docs/clients/restful-api/vertexlabel.md index 7a3c8c1fe..241497098 100644 --- a/content/en/docs/clients/restful-api/vertexlabel.md +++ b/content/en/docs/clients/restful-api/vertexlabel.md @@ -25,7 +25,7 @@ Params Description: ##### Method & Url ``` -POST http://localhost:8080/graphs/hugegraph/schema/vertexlabels +POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/vertexlabels ``` ##### Request Body @@ -124,7 +124,7 @@ Additionally, if the vertex has a property called "createdTime" and you want to ##### Method & Url ``` -PUT http://localhost:8080/graphs/hugegraph/schema/vertexlabels/person?action=append +PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/vertexlabels/person?action=append ``` ##### Request Body @@ -180,7 +180,7 @@ PUT http://localhost:8080/graphs/hugegraph/schema/vertexlabels/person?action=app ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/schema/vertexlabels +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/vertexlabels ``` ##### Response Status @@ -245,7 +245,7 @@ GET http://localhost:8080/graphs/hugegraph/schema/vertexlabels ##### Method & Url ``` -GET http://localhost:8080/graphs/hugegraph/schema/vertexlabels/person +GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/vertexlabels/person ``` ##### Response Status @@ -288,7 +288,7 @@ Deleting a VertexLabel will result in the removal of corresponding vertices and ##### Method & Url ``` -DELETE http://localhost:8080/graphs/hugegraph/schema/vertexlabels/person +DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/vertexlabels/person ``` ##### Response Status @@ -307,4 +307,4 @@ DELETE http://localhost:8080/graphs/hugegraph/schema/vertexlabels/person Note: -> You can use `GET http://localhost:8080/graphs/hugegraph/tasks/1` (where "1" is the task_id) to query the execution status of the asynchronous task. For more information, refer to the [Asynchronous Task RESTful API](../task). +> You can use `GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/1` (where "1" is the task_id) to query the execution status of the asynchronous task. For more information, refer to the [Asynchronous Task RESTful API](../task). diff --git a/content/en/docs/quickstart/hugegraph/hugegraph-server.md b/content/en/docs/quickstart/hugegraph/hugegraph-server.md index d4ecc1d60..226238ae2 100644 --- a/content/en/docs/quickstart/hugegraph/hugegraph-server.md +++ b/content/en/docs/quickstart/hugegraph/hugegraph-server.md @@ -40,13 +40,13 @@ There are four ways to deploy HugeGraph-Server components: #### 3.1 Use Docker container (Convenient for Test/Dev) -You can refer to [Docker deployment guide](https://hub.docker.com/r/hugegraph/hugegraph). +You can refer to the [Docker deployment guide](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-server/hugegraph-dist/docker/README.md). -We can use `docker run -itd --name=graph -e PASSWORD=xxx -p 8080:8080 hugegraph/hugegraph:1.5.0` to quickly start an inner `HugeGraph server` with `RocksDB` in background. +We can use `docker run -itd --name=server -p 8080:8080 -e PASSWORD=xxx hugegraph/hugegraph:1.5.0` to quickly start a `HugeGraph Server` with a built-in `RocksDB` backend. Optional: 1. use `docker exec -it graph bash` to enter the container to do some operations. -2. use `docker run -itd --name=graph -p 8080:8080 -e PRELOAD="true" hugegraph/hugegraph:1.5.0` to start with a **built-in** example graph. We can use `RESTful API` to verify the result. The detailed step can refer to [5.1.9](#519-create-an-example-graph-when-startup) +2. use `docker run -itd --name=graph -p 8080:8080 -e PRELOAD="true" hugegraph/hugegraph:1.5.0` to start with a **built-in** example graph. We can use `RESTful API` to verify the result. The detailed step can refer to [5.1.8](#518-create-an-example-graph-when-startup) 3. use `-e PASSWORD=xxx` to enable auth mode and set the password for admin. You can find more details from [Config Authentication](/docs/config/config-authentication#use-docker-to-enable-authentication-mode) If you use docker desktop, you can set the option like: @@ -74,8 +74,8 @@ services: > Note: > > 1. The docker image of the hugegraph is a convenient release to start it quickly, but not **official distribution** artifacts. You can find more details from [ASF Release Distribution Policy](https://infra.apache.org/release-distribution.html#dockerhub). -> -> 2. Recommend to use `release tag`(like `1.5.0`/`1.5.0`) for the stable version. Use `latest` tag to experience the newest functions in development. +> +> 2. Recommend to use `release tag` (like `1.5.0`/`1.x.0`) for the stable version. Use `latest` tag to experience the newest functions in development. #### 3.2 Download the binary tar tarball @@ -91,9 +91,10 @@ curl https://downloads.apache.org/incubator/hugegraph/{version}/apache-hugegraph ``` #### 3.3 Source code compilation -Please ensure that the wget command is installed before compiling the source code -We could get HugeGraph **source code** in 2 ways: (So as the other HugeGraph repos/modules) +Please ensure that the wget/curl commands are installed before compiling the source code + +Download HugeGraph **source code** in either of the following 2 ways (so as the other HugeGraph repos/modules): - download the stable/release version from the ASF site - clone the unstable/latest version by GitBox(ASF) or GitHub @@ -193,7 +194,7 @@ If you need to access HugeGraphServer externally, please modify the `restserver. Since the configuration (hugegraph.properties) and startup steps required by various backends are slightly different, the following will introduce the configuration and startup of each backend one by one. -Follow the [Server Authentication Configuration](/docs/config/config-authentication/) before you start Server later. +**Note:** Configure [Server Authentication](/docs/config/config-authentication/) before starting HugeGraphServer if you need Auth mode (especially for production or public network environments). ##### 5.1.1 Distributed Storage (HStore) @@ -215,10 +216,17 @@ task.scheduler_type=distributed pd.peers=127.0.0.1:8686,127.0.0.1:8687,127.0.0.1:8688 ``` +Then enable PD discovery in `rest-server.properties` (required for every HugeGraph-Server node): + +```properties +usePD=true +``` + If configuring multiple HugeGraph-Server nodes, you need to modify the `rest-server.properties` configuration file for each node, for example: Node 1 (Master node): ```properties +usePD=true restserver.url=http://127.0.0.1:8081 gremlinserver.url=http://127.0.0.1:8181 @@ -231,6 +239,7 @@ server.role=master Node 2 (Worker node): ```properties +usePD=true restserver.url=http://127.0.0.1:8082 gremlinserver.url=http://127.0.0.1:8182