You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hugegraph.apache.org by ji...@apache.org on 2026/09/30 17:09:48 UTC
(hugegraph-doc) branch docs/align-toolchain-master created (now 4ec21d9ac)
This is an automated email from the ASF dual-hosted git repository.
imbajin pushed a change to branch docs/align-toolchain-master
in repository https://gitbox.apache.org/repos/asf/hugegraph-doc.git
at 4ec21d9ac docs(toolchain): align client and loader guides
This branch includes the following new commits:
new 4ec21d9ac docs(toolchain): align client and loader guides
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(hugegraph-doc) 01/01: docs(toolchain): align client and loader guides
Posted by ji...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
imbajin pushed a commit to branch docs/align-toolchain-master
in repository https://gitbox.apache.org/repos/asf/hugegraph-doc.git
commit 4ec21d9ac4b5adb140c22cbfa800e1ec76959ed8
Author: imbajin <ji...@apache.org>
AuthorDate: Thu Oct 1 01:09:39 2026 +0800
docs(toolchain): align client and loader guides
- align client examples and dependencies with master
- repair loader schema, data and mapping examples
- clarify timeout, header and driver behavior
- verify bilingual examples and site checks
---
content/cn/docs/clients/hugegraph-client.md | 21 +++++-
.../cn/docs/quickstart/client/hugegraph-client.md | 13 +++-
.../docs/quickstart/toolchain/hugegraph-loader.md | 81 +++++++++------------
content/en/docs/clients/hugegraph-client.md | 21 +++++-
.../en/docs/quickstart/client/hugegraph-client.md | 15 +++-
.../docs/quickstart/toolchain/hugegraph-loader.md | 83 +++++++++-------------
6 files changed, 126 insertions(+), 108 deletions(-)
diff --git a/content/cn/docs/clients/hugegraph-client.md b/content/cn/docs/clients/hugegraph-client.md
index 8d357c3f2..3e9b618ec 100644
--- a/content/cn/docs/clients/hugegraph-client.md
+++ b/content/cn/docs/clients/hugegraph-client.md
@@ -9,6 +9,9 @@ weight: 2
用户在`HugeGraph-Hubble`中编写的`gremlin(groovy)`可以参考本文的`java`代码,下面会举出几个例子。
+本文以 Toolchain `master`(Client `1.8.0`)为准。请先按[快速入门](/cn/docs/quickstart/client/hugegraph-client/)准备对应依赖;
+能力探测等新增接口不能直接用于旧版 Client。
+
### 1 HugeGraph-Client
HugeGraph-Client 是操作 graph 的总入口,用户必须先创建出 HugeGraph-Client 对象,与 HugeGraph-Server 建立连接(伪连接)后,才能获取到 schema、graph 以及 gremlin 的操作入口对象。
@@ -21,7 +24,7 @@ HugeGraph-Client 连接服务端已有的图。构造器支持传入 GraphSpace
HugeClient hugeClient = HugeClient.builder("http://localhost:8080", "hugegraph")
//.builder("http://localhost:8080", "graphSpaceName", "hugegraph")
.configTimeout(20) // 默认 20s 超时
- .configUser("**", "**") // 默认未开启用户权限
+ // .configUser("username", "password") // 服务端启用认证时配置
.build();
```
@@ -40,7 +43,7 @@ HugeClient hugeClient = HugeClient.builder("http://localhost:8080", "hugegraph")
| `configGraphSpace(String graphSpace)` | GraphSpace 名称,传入 null 或空值时回退为 `DEFAULT` | `DEFAULT` |
| `configUser(String username, String password)` | 服务端用户名和密码,传入 null 时按空字符串处理 | 空,不开启认证 |
| `configToken(String token)` | 使用 Token 代替用户名和密码 | 空 |
-| `configTimeout(int seconds)` | 请求超时,传入 `0` 时恢复默认值 | 20 |
+| `configTimeout(int seconds)` | 请求超时,建议使用正数秒值 | 20 |
| `configConnectTimeout(Integer seconds)` | 连接超时,不设置时沿用 `configTimeout` | 未设置 |
| `configReadTimeout(Integer seconds)` | 读取超时,不设置时沿用 `configTimeout` | 未设置 |
| `configPool(int maxConns, int maxConnsPerRoute)` | 连接池大小,任意一项传入 `0` 时恢复其默认值 | 4 x CPU 数,2 x CPU 数 |
@@ -49,6 +52,9 @@ HugeClient hugeClient = HugeClient.builder("http://localhost:8080", "hugegraph")
| `configHttpBuilder(Consumer<OkHttpClient.Builder> consumer)` | 回调,用于进一步定制底层的 OkHttp 客户端 | 无 |
| `graphRequired(boolean graphRequired)` | `build()` 是否拒绝空的 url 或图名称 | true |
+当前 master 的 `configTimeout(0)` 存在单位换算缺陷,会得到 20,000 秒而非默认的 20 秒。
+保持默认值时省略该调用,或显式使用 `configTimeout(20)`;不要用 `0` 恢复默认值。
+
调用 `build()` 时,客户端会读取服务端的 API 版本,超出 `[0.38, 0.81)` 范围时报错。
#### 1.2 操作入口
@@ -493,10 +499,19 @@ IndexLabel 允许定义的约束信息包括:name、baseType、baseValue、ind
##### 2.5.2 创建 IndexLabel
+以下示例假定已创建带 `name`、`age` 的 `person` 顶点类型,以及带 `date` 的 `created` 边类型。
+先补充索引所需属性;`id` 是业务属性,与顶点的内部 ID 不同。
+
```java
+schema.propertyKey("lived").asText().ifNotExist().create();
+schema.propertyKey("city").asText().ifNotExist().create();
+schema.propertyKey("id").asInt().ifNotExist().create();
+schema.vertexLabel("person").properties("lived", "city", "id")
+ .nullableKeys("lived", "city", "id").append();
+
schema.indexLabel("personByAge").onV("person").by("age").range().ifNotExist().create();
schema.indexLabel("createdByDate").onE("created").by("date").secondary().ifNotExist().create();
-schema.indexLabel("personByLived").onE("person").by("lived").search().ifNotExist().create();
+schema.indexLabel("personByLived").onV("person").by("lived").search().ifNotExist().create();
schema.indexLabel("personByCityAndAge").onV("person").by("city", "age").shard().ifNotExist().create();
schema.indexLabel("personById").onV("person").by("id").unique().ifNotExist().create();
```
diff --git a/content/cn/docs/quickstart/client/hugegraph-client.md b/content/cn/docs/quickstart/client/hugegraph-client.md
index 67e81c98a..cfaf356cc 100644
--- a/content/cn/docs/quickstart/client/hugegraph-client.md
+++ b/content/cn/docs/quickstart/client/hugegraph-client.md
@@ -44,12 +44,19 @@ weight: 1
<dependency>
<groupId>org.apache.hugegraph</groupId>
<artifactId>hugegraph-client</artifactId>
- <!-- 请按下载页选择已发布版本 -->
- <version>1.7.0</version>
+ <!-- 与本文的 Toolchain master 对应 -->
+ <version>1.8.0</version>
</dependency>
</dependencies>
```
-> Client 与 Server 的开发版本可能不同。升级前应按对应发布说明核对兼容性。
+本文以 Toolchain `master`(`1.8.0`)为准。若此版本尚未发布到 Maven 仓库,在 Toolchain 源码根目录运行以下命令,
+将 Client 及其父 POM 安装到本地 Maven 仓库后,再构建示例工程。源码构建的依赖仍需能够从配置的 Maven 仓库获取。
+
+```bash
+mvn install -pl hugegraph-client -am -DskipTests -Dmaven.javadoc.skip=true -ntp
+```
+
+Client 与 Server 的版本不必相同;升级前核对服务端 API 兼容范围及所需功能。旧版 Client 不一定提供本文使用的接口。
#### 4.3 Example
diff --git a/content/cn/docs/quickstart/toolchain/hugegraph-loader.md b/content/cn/docs/quickstart/toolchain/hugegraph-loader.md
index b06f8fa4a..608746e15 100644
--- a/content/cn/docs/quickstart/toolchain/hugegraph-loader.md
+++ b/content/cn/docs/quickstart/toolchain/hugegraph-loader.md
@@ -6,6 +6,8 @@ search_keywords: [HugeGraph Loader, 批量导入, 数据导入]
search_boost: 1.6
---
+本文以 Toolchain `master`(当前版本为 `1.8.0`)为准。发布版和 Docker `latest` 可能与源码不同;使用时请核对版本,未发布的版本请按下文从源码构建。
+
### 1 HugeGraph-Loader 概述
HugeGraph-Loader 是 HugeGraph 的数据导入组件,能够将多种数据源的数据转化为图的顶点和边并批量导入到图数据库中。
@@ -37,7 +39,7 @@ HugeGraph-Loader 是 HugeGraph 的数据导入组件,能够将多种数据源
#### 2.1 使用 Docker 镜像 (便于**测试**)
-我们可以使用 `docker run -itd --name loader hugegraph/loader:1.7.0` 部署 loader 服务。对于需要加载的数据,则可以通过挂载 `-v /path/to/data/file:/loader/file` 或者 `docker cp` 的方式将文件复制到 loader 容器内部。
+我们可以使用 `docker run -itd --name loader hugegraph/loader:latest` 部署 loader 服务。对于需要加载的数据,则可以通过挂载 `-v /path/to/data/file:/loader/file` 或者 `docker cp` 的方式将文件复制到 loader 容器内部。
或者使用 docker-compose 启动 loader, 启动命令为 `docker-compose up -d`, 样例的 docker-compose.yml 如下所示:
@@ -46,21 +48,15 @@ version: '3'
services:
server:
- image: hugegraph/hugegraph:1.7.0
+ image: hugegraph/hugegraph:latest
container_name: server
environment:
- PASSWORD=xxx
ports:
- 8080:8080
- hubble:
- image: hugegraph/hubble:1.7.0
- container_name: hubble
- ports:
- - 8088:8088
-
loader:
- image: hugegraph/loader:1.7.0
+ image: hugegraph/loader:latest
container_name: loader
# mount your own data here
# volumes:
@@ -74,44 +70,21 @@ services:
>
> 1. hugegraph-loader 的 docker 镜像是一个便捷版本,用于快速启动 loader,并不是**官方发布物料包方式**。你可以从 [ASF Release Distribution Policy](https://infra.apache.org/release-distribution.html#dockerhub) 中得到更多细节。
>
-> 2. 推荐使用 `release tag` (如 `1.7.0`) 以获取稳定版。使用 `latest` tag 可以使用开发中的最新功能。
+> 2. 生产环境应固定已发布的版本标签或镜像 digest。`latest` 是可变标签,不能据此判断其与 `master` 一致。
#### 2.2 下载已编译的压缩包
-下载最新版本的 `HugeGraph-Toolchain` Release 包,里面包含了 `loader + tool + hubble` 全套工具,如果你已经下载,可跳过重复步骤
-
-```bash
-export VERSION=1.7.0
-export ARCHIVE="apache-hugegraph-toolchain-incubating-${VERSION}"
-wget "https://downloads.apache.org/hugegraph/${VERSION}/${ARCHIVE}.tar.gz"
-tar zxf "${ARCHIVE}.tar.gz"
-```
+从 [下载页面](/cn/docs/download/download) 选择已发布的 Toolchain 压缩包并解压。
+发布包不一定包含 `master` 的全部功能;需要本文对应实现时,使用下一节的源码构建方式。
#### 2.3 克隆源码编译安装
-克隆最新版本的 HugeGraph-Loader 源码包:
+克隆 `master` 分支:
```bash
-# 1. get from github
-git clone https://github.com/apache/hugegraph-toolchain.git
-
-# 2. 下载发布版源码包
-export VERSION=1.7.0
-export ARCHIVE="apache-hugegraph-toolchain-incubating-${VERSION}"
-wget "https://downloads.apache.org/hugegraph/${VERSION}/${ARCHIVE}-src.tar.gz"
+git clone --branch master --single-branch https://github.com/apache/hugegraph-toolchain.git
```
-> [!DETAILS]- 点击展开/折叠 手动安装 ojdbc 方法
-> 由于 Oracle ojdbc license 的限制,需要手动安装 ojdbc 到本地 maven 仓库。
-> 访问 [Oracle jdbc 下载](https://www.oracle.com/database/technologies/appdev/jdbc-drivers-archive.html) 页面。选择 Oracle Database 12c Release 2 (12.2.0.1) drivers,如下图所示。
->
-> 打开链接后,选择“ojdbc8.jar”
->
-> 把 ojdbc8 安装到本地 maven 仓库,进入`ojdbc8.jar`所在目录,执行以下命令。
-> ```
-> mvn install:install-file -Dfile=./ojdbc8.jar -DgroupId=com.oracle -DartifactId=ojdbc8 -Dversion=12.2.0.1 -Dpackaging=jar
-> ```
-
编译生成 tar 包:
```bash
@@ -119,6 +92,9 @@ cd hugegraph-toolchain
mvn clean package -pl hugegraph-loader -am -DskipTests -ntp
```
+如需读取 Oracle 数据,按所用 Oracle/JDK 版本准备兼容的 JDBC 驱动 JAR,并放入解压后 Loader 的 `lib/` 目录。
+启动脚本会加载该目录中的 JAR;仅将驱动安装到 Maven 本地仓库并不会让运行中的 Loader 找到它。
+
### 3 使用流程
使用 HugeGraph-Loader 的基本流程分为以下几步:
@@ -156,7 +132,7 @@ schema.vertexLabel("person").properties("name", "age", "city").primaryKeys("name
schema.vertexLabel("software").properties("name", "price").primaryKeys("name").ifNotExist().create();
// 创建 knows 边类型,这类边是从 person 指向 person 的
-schema.edgeLabel("knows").sourceLabel("person").targetLabel("person").ifNotExist().create();
+schema.edgeLabel("knows").sourceLabel("person").targetLabel("person").properties("date").ifNotExist().create();
// 创建 created 边类型,这类边是从 person 指向 software 的
schema.edgeLabel("created").sourceLabel("person").targetLabel("software").ifNotExist().create();
```
@@ -614,7 +590,7 @@ bin/utf8-bom-to-utf8.sh /path/to/file-or-dir
- path: 本地文件或目录的路径,绝对路径或相对于 Loader 进程当前工作目录的相对路径,必填;为避免工作目录不同导致找不到文件,建议使用绝对路径;
- file_filter: 从`path`中筛选复合条件的文件,复合结构,目前只支持配置扩展名,用子节点`extensions`表示,默认为"*",表示保留所有文件;
- format: 本地文件的格式,可选值为 CSV、TEXT 及 JSON,必须大写,默认为 CSV,选填;
- - header: 文件各列的列名,如不指定则会以数据文件第一行作为 header;当文件本身有标题且又指定了 header,文件的第一行会被当作普通的数据行;JSON 文件不需要指定 header,选填;
+ - header: 文件各列的列名,如不指定则以数据文件第一行作为 header;显式指定时,首行若与 header 完全相同,默认仍会跳过,详见 has_header;JSON 文件不需要指定 header,选填;
- has_header: 对 CSV 和 TEXT 格式,如果某个文件的首行与 header 完全相同,该行会被丢弃,这样目录下每个分片文件重复的表头不会被当作数据导入。如果分片文件的首行是恰好与 header 相同的真实数据,可以设为 `false` 关闭这个检查,选填;
- delimiter: 文件行的列分隔符。默认值取决于`format`:CSV 为逗号`","`,TEXT 为制表符`"\t"`;CSV 只接受逗号。`JSON`文件不需要指定,选填;
- charset: 文件的编码字符集,默认`UTF-8`,选填;
@@ -838,7 +814,7 @@ GRAPH 输入源从另一个 HugeGraph 图(通过 HugeGraph-PD 访问)读取
| `--pd-peers` | | | PD 服务节点地址 |
| `--pd-token` | | | 访问 PD 服务的 token |
| `--meta-endpoints` | | | 元信息存储服务地址 |
-| `--direct` | false | | 是否直连 HugeGraph-Store |
+| `--direct` | false | | 当前 master 未启用 Store 直连,仍经 Server API 导入;保留默认值 |
| `--route-type` | NODE_PORT | | 路由选择方式(可选值:NODE_PORT / DDS / BOTH) |
| `--cluster` | hg | | 集群名 |
| `--trust-store-file` | | | 请求协议为 https 时,客户端的证书文件路径 |
@@ -1020,10 +996,10 @@ id|name|lang|price|ISBN
边文件:`example/file/edge_created.json`
```json
-{"aname": "marko", "bname": "lop", "date": "20171210", "weight": 0.4}
-{"aname": "josh", "bname": "lop", "date": "20091111", "weight": 0.4}
-{"aname": "josh", "bname": "ripple", "date": "20171210", "weight": 1.0}
-{"aname": "peter", "bname": "lop", "date": "20170324", "weight": 0.2}
+{"source_name": "marko", "target_id": 1, "date": "2017-12-10", "weight": 0.4}
+{"source_name": "josh", "target_id": 1, "date": "2009-11-11", "weight": 0.4}
+{"source_name": "josh", "target_id": 2, "date": "2017-12-10", "weight": 1.0}
+{"source_name": "peter", "target_id": 1, "date": "2017-03-24", "weight": 0.2}
```
#### 4.2 编写 schema
@@ -1038,8 +1014,8 @@ id|name|lang|price|ISBN
> schema.propertyKey("date").asText().ifNotExist().create();
> schema.propertyKey("price").asDouble().ifNotExist().create();
>
-> schema.vertexLabel("person").properties("name", "age", "city").primaryKeys("name").ifNotExist().create();
-> schema.vertexLabel("software").properties("name", "lang", "price").primaryKeys("name").ifNotExist().create();
+> schema.vertexLabel("person").properties("name", "age", "city").primaryKeys("name").nullableKeys("age", "city").ifNotExist().create();
+> schema.vertexLabel("software").useCustomizeNumberId().properties("name", "lang", "price").ifNotExist().create();
>
> schema.indexLabel("personByAge").onV("person").by("age").range().ifNotExist().create();
> schema.indexLabel("personByCity").onV("person").by("city").secondary().ifNotExist().create();
@@ -1054,6 +1030,10 @@ id|name|lang|price|ISBN
> schema.indexLabel("knowsByWeight").onE("knows").by("weight").range().ifNotExist().create();
> ```
+`person` 使用 `name` 作为主键;Tom 的 `age` 和 `city` 会被 `null_values` 去掉,因此这两个属性必须允许为空。
+`software` 使用自定义数值 ID,映射中的 `id` 和 `created.target_id` 分别对应顶点 ID 及边的目标 ID。
+请在未包含同名 Schema 的空图中执行,避免 `ifNotExist()` 保留已有的不兼容定义。
+
#### 4.3 编写输入源映射文件`example/file/struct.json`
> [!DETAILS]- 点击展开/折叠 源映射文件 example/file/struct.json
@@ -1198,6 +1178,9 @@ docker exec -it loader bin/hugegraph-loader.sh -g hugegraph -f example/file/stru
docker exec -it loader bin/hugegraph-loader.sh -g hugegraph -f /loader/dataset/struct.json -s /loader/dataset/schema.groovy -h server -p 8080
```
+自定义数据集的 `struct.json` 还需将每个 `input.path` 改为容器内实际路径,例如 `/loader/dataset/vertex_person.csv`。
+只修改 `-f` 和 `-s` 不会改变数据文件的解析路径。
+
> 如果 `loader` 和 `server`位于同一 docker 网络,则可以指定 `-h {server_container_name}`, 否则需要指定 `server`的宿主机的 ip (在我们的例子中, `server_container_name` 为 `server`).
@@ -1231,12 +1214,14 @@ meter metrics
也可以使用 `curl` 或者 `hubble`观察导入结果,此处以 `curl` 为例:
+以下使用支持 GraphSpace 的 Server API;旧版 Server 的路径需去掉 `/graphspaces/DEFAULT`。
+
```bash
-> curl "http://localhost:8080/graphs/hugegraph/graph/vertices" | gunzip
+curl --compressed "http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices"
{"vertices":[{"id":1,"label":"software","type":"vertex","properties":{"name":"lop","lang":"java","price":328.0}},{"id":2,"label":"software","type":"vertex","properties":{"name":"ripple","lang":"java","price":199.0}},{"id":"1:tom","label":"person","type":"vertex","properties":{"name":"tom"}},{"id":"1:josh","label":"person","type":"vertex","properties":{"name":"josh","age":32,"city":"Beijing"}},{"id":"1:marko","label":"person","type":"vertex","properties":{"name":"marko","age":29,"city":"B [...]
```
-如果想检查边的导入结果,可以使用 `curl "http://localhost:8080/graphs/hugegraph/graph/edges" | gunzip`
+如果想检查边的导入结果,可以使用 `curl --compressed "http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges"`
##### 4.5.2 进入 docker 容器进行导入
diff --git a/content/en/docs/clients/hugegraph-client.md b/content/en/docs/clients/hugegraph-client.md
index a0d50d2d5..0ae4a0143 100644
--- a/content/en/docs/clients/hugegraph-client.md
+++ b/content/en/docs/clients/hugegraph-client.md
@@ -8,6 +8,9 @@ The code in this document is written in `java`, but its style is very similar to
You can convert `java` code into `groovy`; in addition, each line of statement can be without a semicolon at the end, `groovy` considers a line to be a statement.
The `gremlin(groovy)` written by the user in `HugeGraph-Studio` can refer to the `java` code in this document, and some examples will be given below.
+This reference follows Toolchain `master` (Client `1.8.0`). Prepare the matching dependency using the
+[quickstart](/docs/quickstart/client/hugegraph-client/); newly added APIs such as capability detection are unavailable in older clients.
+
### 1 HugeGraph-Client
HugeGraph-Client is the general entry for operating graph. Users must first create a HugeGraph-Client object and establish a connection (pseudo connection) with HugeGraph-Server before they can obtain the operation entry objects of schema, graph and gremlin.
@@ -20,7 +23,7 @@ HugeGraph-Client connects to an existing graph on the server. Its builder accept
HugeClient hugeClient = HugeClient.builder("http://localhost:8080", "hugegraph")
//.builder("http://localhost:8080", "graphSpaceName", "hugegraph")
.configTimeout(20) // 20s timeout
- .configUser("**", "**") // enable auth
+ // .configUser("username", "password") // set only when server auth is enabled
.build();
```
@@ -39,7 +42,7 @@ The builder accepts the following options. Every timeout is expressed in seconds
| `configGraphSpace(String graphSpace)` | GraphSpace name, a null or empty value falls back to `DEFAULT` | `DEFAULT` |
| `configUser(String username, String password)` | Credentials for the server, a null value is stored as an empty string | empty, no auth |
| `configToken(String token)` | Token used instead of username and password | empty |
-| `configTimeout(int seconds)` | Request timeout, passing `0` restores the default | 20 |
+| `configTimeout(int seconds)` | Request timeout; use a positive number of seconds | 20 |
| `configConnectTimeout(Integer seconds)` | Connect timeout, left unset so that `configTimeout` applies | unset |
| `configReadTimeout(Integer seconds)` | Read timeout, left unset so that `configTimeout` applies | unset |
| `configPool(int maxConns, int maxConnsPerRoute)` | Connection pool sizes, passing `0` for either one restores its default | 4 x CPUs, 2 x CPUs |
@@ -48,6 +51,9 @@ The builder accepts the following options. Every timeout is expressed in seconds
| `configHttpBuilder(Consumer<OkHttpClient.Builder> consumer)` | Callback that receives the underlying OkHttp builder for further customization | none |
| `graphRequired(boolean graphRequired)` | Whether `build()` rejects an empty url or graph name | true |
+Current master has a unit-conversion defect in `configTimeout(0)`: it sets 20,000 seconds instead of the default 20 seconds.
+Omit the call to keep the default, or use `configTimeout(20)` explicitly; do not use `0` to reset it.
+
On `build()`, the client reads the server API version and rejects anything outside the range `[0.38, 0.81)`.
#### 1.2 Operation entries
@@ -481,10 +487,19 @@ The constraint information that IndexLabel allows to define include: name, baseT
##### 2.5.2 Create IndexLabel
+These examples assume a `person` vertex label with `name` and `age`, and a `created` edge label with `date`.
+First add the indexed properties below; `id` is a business property, separate from the internal vertex ID.
+
```java
+schema.propertyKey("lived").asText().ifNotExist().create();
+schema.propertyKey("city").asText().ifNotExist().create();
+schema.propertyKey("id").asInt().ifNotExist().create();
+schema.vertexLabel("person").properties("lived", "city", "id")
+ .nullableKeys("lived", "city", "id").append();
+
schema.indexLabel("personByAge").onV("person").by("age").range().ifNotExist().create();
schema.indexLabel("createdByDate").onE("created").by("date").secondary().ifNotExist().create();
-schema.indexLabel("personByLived").onE("person").by("lived").search().ifNotExist().create();
+schema.indexLabel("personByLived").onV("person").by("lived").search().ifNotExist().create();
schema.indexLabel("personByCityAndAge").onV("person").by("city", "age").shard().ifNotExist().create();
schema.indexLabel("personById").onV("person").by("id").unique().ifNotExist().create();
```
diff --git a/content/en/docs/quickstart/client/hugegraph-client.md b/content/en/docs/quickstart/client/hugegraph-client.md
index c8c2691d9..3c990eba6 100644
--- a/content/en/docs/quickstart/client/hugegraph-client.md
+++ b/content/en/docs/quickstart/client/hugegraph-client.md
@@ -41,12 +41,21 @@ Using IDEA or Eclipse to create the project:
<dependency>
<groupId>org.apache.hugegraph</groupId>
<artifactId>hugegraph-client</artifactId>
- <!-- Select a released version from the download page -->
- <version>1.7.0</version>
+ <!-- Matches the Toolchain master used in this guide -->
+ <version>1.8.0</version>
</dependency>
</dependencies>
```
-> Development versions of the client and server may differ. Check the corresponding release notes for compatibility before upgrading.
+This guide follows Toolchain `master` (`1.8.0`). If this version is not yet published to Maven, run the following command
+from the Toolchain source root to install the Client and its parent POM locally before building the example project.
+The source build still needs its dependencies available from your configured Maven repositories.
+
+```bash
+mvn install -pl hugegraph-client -am -DskipTests -Dmaven.javadoc.skip=true -ntp
+```
+
+Client and Server versions need not match. Check the supported server API range and required capabilities before upgrading;
+older clients may not provide the APIs used in this guide.
#### 4.3 Example
diff --git a/content/en/docs/quickstart/toolchain/hugegraph-loader.md b/content/en/docs/quickstart/toolchain/hugegraph-loader.md
index 6d98fde8c..c0c754c0d 100644
--- a/content/en/docs/quickstart/toolchain/hugegraph-loader.md
+++ b/content/en/docs/quickstart/toolchain/hugegraph-loader.md
@@ -7,6 +7,9 @@ search_boost: 1.6
description: "Bulk import graph data into HugeGraph with Loader from files, HDFS, relational databases, Kafka, and other HugeGraph graphs."
---
+This guide follows Toolchain `master` (currently `1.8.0`). Released packages and Docker `latest` may differ from source;
+check the version you use and build from source for unreleased functionality.
+
### 1 HugeGraph-Loader Overview
HugeGraph-Loader is the data import component of HugeGraph, which can convert data from various data sources into graph vertices and edges and import them into the graph database in batches.
@@ -36,7 +39,7 @@ HugeGraph-Loader is available in the following three ways:
#### 2.1 Use Docker image (Convenient for Test/Dev)
-We can deploy the loader service using `docker run -itd --name loader hugegraph/loader:1.7.0`. For the data that needs to be loaded, it can be copied into the loader container either by mounting `-v /path/to/data/file:/loader/file` or by using `docker cp`.
+We can deploy the loader service using `docker run -itd --name loader hugegraph/loader:latest`. For the data that needs to be loaded, it can be copied into the loader container either by mounting `-v /path/to/data/file:/loader/file` or by using `docker cp`.
Alternatively, to start the loader using docker-compose, the command is `docker-compose up -d`. An example of the docker-compose.yml is as follows:
@@ -45,19 +48,13 @@ version: '3'
services:
server:
- image: hugegraph/hugegraph:1.7.0
+ image: hugegraph/hugegraph:latest
container_name: server
ports:
- 8080:8080
- hubble:
- image: hugegraph/hubble:1.7.0
- container_name: hubble
- ports:
- - 8088:8088
-
loader:
- image: hugegraph/loader:1.7.0
+ image: hugegraph/loader:latest
container_name: loader
# mount your own data here
# volumes:
@@ -69,44 +66,21 @@ The specific data loading process can be referenced under [4.5 User Docker to lo
> Note:
> 1. The docker image of hugegraph-loader is a convenience release to start hugegraph-loader 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.7.0`) for the stable version. Use `latest` tag to experience the newest functions in development.
+> 2. Pin a published version tag or image digest in production. `latest` is mutable and does not guarantee alignment with `master`.
#### 2.2 Download the compiled archive
-Download the latest version of the HugeGraph-Toolchain release package:
-
-```bash
-export VERSION=1.7.0
-export ARCHIVE="apache-hugegraph-toolchain-incubating-${VERSION}"
-wget "https://downloads.apache.org/hugegraph/${VERSION}/${ARCHIVE}.tar.gz"
-tar zxf "${ARCHIVE}.tar.gz"
-```
+Choose a published Toolchain archive from the [download page](/docs/download/download) and extract it.
+A release may not include all `master` functionality; use the source build below for the implementation described here.
#### 2.3 Clone source code to compile and install
-Clone the latest version of HugeGraph-Loader source package:
+Clone the `master` branch:
```bash
-# 1. get from github
-git clone https://github.com/apache/hugegraph-toolchain.git
-
-# 2. Download a released source package
-export VERSION=1.7.0
-export ARCHIVE="apache-hugegraph-toolchain-incubating-${VERSION}"
-wget "https://downloads.apache.org/hugegraph/${VERSION}/${ARCHIVE}-src.tar.gz"
+git clone --branch master --single-branch https://github.com/apache/hugegraph-toolchain.git
```
-> [!DETAILS]- How to install OJDBC
-> Due to the license limitation of the `Oracle OJDBC`, you need to manually install ojdbc to the local maven repository.
-> Visit the [Oracle jdbc downloads](https://www.oracle.com/database/technologies/appdev/jdbc-drivers-archive.html) page. Select Oracle Database 12c Release 2 (12.2.0.1) drivers, as shown in the following figure.
->
-> After opening the link, select "ojdbc8.jar".
->
-> Install ojdbc8 to the local maven repository, enter the directory where `ojdbc8.jar` is located, and execute the following command.
-> ```
-> mvn install:install-file -Dfile=./ojdbc8.jar -DgroupId=com.oracle -DartifactId=ojdbc8 -Dversion=12.2.0.1 -Dpackaging=jar
-> ```
-
Compile and generate tar package:
```bash
@@ -114,6 +88,9 @@ cd hugegraph-toolchain
mvn clean package -pl hugegraph-loader -am -DskipTests -ntp
```
+For Oracle input, obtain a JDBC driver JAR compatible with your Oracle/JDK versions and place it in the extracted Loader `lib/` directory.
+The startup script loads JARs there; installing a driver only in the local Maven repository does not put it on Loader’s runtime classpath.
+
### 3 How to use
The basic process of using HugeGraph-Loader is divided into the following steps:
- Write graph schema
@@ -150,7 +127,7 @@ schema.vertexLabel("person").properties("name", "age", "city").primaryKeys("name
schema.vertexLabel("software").properties("name", "price").primaryKeys("name").ifNotExist().create();
// Create the knows edge type, which goes from person to person
-schema.edgeLabel("knows").sourceLabel("person").targetLabel("person").ifNotExist().create();
+schema.edgeLabel("knows").sourceLabel("person").targetLabel("person").properties("date").ifNotExist().create();
// Create the created edge type, which points from person to software
schema.edgeLabel("created").sourceLabel("person").targetLabel("software").ifNotExist().create();
```
@@ -609,7 +586,8 @@ Input sources are currently divided into five categories: FILE, HDFS, JDBC, KAFK
- path: the path of the local file or directory, an absolute path or a path relative to the Loader process working directory (not the mapping file). An absolute path is recommended; required;
- file_filter: filter files with compound conditions from `path`, compound structure, currently only supports configuration extensions, represented by child node `extensions`, the default is "*", which means to keep all files;
- format: the format of the local file, the optional values are CSV, TEXT and JSON, which must be uppercase, the default is CSV, optional;
- - header: the column name of each column of the file, if not specified, the first line of the data file will be used as the header; when the file itself has a header and the header is specified, the first line of the file will be treated as a normal data line; JSON The file does not need to specify a header, optional;
+ - header: column names; if omitted, the first data line supplies them. With an explicit header, an identical first line is still skipped by default
+ (see has_header). JSON does not require a header; optional;
- has_header: for CSV and TEXT, the first line of every file is dropped when it is identical to the header, so a header repeated in each part file of a directory is not imported as data. Set this to `false` to turn that check off when the first line of a file is real data that happens to equal the header, optional;
- delimiter: The column delimiter of the file line. The default depends on `format`: a comma `","` for CSV and a tab `"\t"` for TEXT; a CSV file accepts no other delimiter. The `JSON` file does not need to be specified, optional;
- charset: the encoded character set of the file, the default is `UTF-8`, optional;
@@ -833,7 +811,7 @@ The import process is controlled by commands submitted by the user, and the user
| `--pd-peers` | | | PD service node addresses |
| `--pd-token` | | | Token for accessing PD service |
| `--meta-endpoints` | | | Meta information storage service addresses |
-| `--direct` | false | | Whether to directly connect to HugeGraph-Store |
+| `--direct` | false | | Store direct mode is disabled in current master; imports still use Server API. Keep the default |
| `--route-type` | NODE_PORT | | Route selection method (optional values: NODE_PORT / DDS / BOTH) |
| `--cluster` | hg | | Cluster name |
| `--trust-store-file` | | | When the request protocol is https, the client's certificate file path |
@@ -1017,10 +995,10 @@ Edge file: `example/file/edge_knows.json`
Edge file: `example/file/edge_created.json`
```json
-{"aname": "marko", "bname": "lop", "date": "20171210", "weight": 0.4}
-{"aname": "josh", "bname": "lop", "date": "20091111", "weight": 0.4}
-{"aname": "josh", "bname": "ripple", "date": "20171210", "weight": 1.0}
-{"aname": "peter", "bname": "lop", "date": "20170324", "weight": 0.2}
+{"source_name": "marko", "target_id": 1, "date": "2017-12-10", "weight": 0.4}
+{"source_name": "josh", "target_id": 1, "date": "2009-11-11", "weight": 0.4}
+{"source_name": "josh", "target_id": 2, "date": "2017-12-10", "weight": 1.0}
+{"source_name": "peter", "target_id": 1, "date": "2017-03-24", "weight": 0.2}
```
#### 4.2 Write schema
@@ -1035,8 +1013,8 @@ Edge file: `example/file/edge_created.json`
> schema.propertyKey("date").asText().ifNotExist().create();
> schema.propertyKey("price").asDouble().ifNotExist().create();
>
-> schema.vertexLabel("person").properties("name", "age", "city").primaryKeys("name").ifNotExist().create();
-> schema.vertexLabel("software").properties("name", "lang", "price").primaryKeys("name").ifNotExist().create();
+> schema.vertexLabel("person").properties("name", "age", "city").primaryKeys("name").nullableKeys("age", "city").ifNotExist().create();
+> schema.vertexLabel("software").useCustomizeNumberId().properties("name", "lang", "price").ifNotExist().create();
>
> schema.indexLabel("personByAge").onV("person").by("age").range().ifNotExist().create();
> schema.indexLabel("personByCity").onV("person").by("city").secondary().ifNotExist().create();
@@ -1051,6 +1029,10 @@ Edge file: `example/file/edge_created.json`
> schema.indexLabel("knowsByWeight").onE("knows").by("weight").range().ifNotExist().create();
> ```
+`person` uses `name` as its primary key. Tom’s `age` and `city` are removed by `null_values`, so both properties must be nullable.
+`software` uses custom numeric IDs: mapping `id` supplies the vertex ID and `created.target_id` supplies the edge’s target ID.
+Run this example in an empty graph without these schema labels; `ifNotExist()` does not replace incompatible existing definitions.
+
#### 4.3 Write the input source mapping file `example/file/struct.json`
> [!DETAILS]- Click to expand/collapse the input source mapping file example/file/struct.json
@@ -1195,6 +1177,9 @@ If loading a custom dataset, following the previous example, you would use:
docker exec -it loader bin/hugegraph-loader.sh -g hugegraph -f /loader/dataset/struct.json -s /loader/dataset/schema.groovy -h server -p 8080
```
+Also update every `input.path` in the custom `struct.json` to its actual container path, such as `/loader/dataset/vertex_person.csv`.
+Changing only `-f` and `-s` does not change where Loader looks for data files.
+
> If `loader` and `server` are in the same Docker network, you can specify `-h {server_container_name}`; otherwise, you need to specify the IP of the `server` host (in our example, `server_container_name` is `server`).
Then we can see the result:
@@ -1227,12 +1212,14 @@ meter metrics
You can also use `curl` or `hubble` to observe the import result. Here's an example using `curl`:
+These requests use the GraphSpace-aware Server API. For an older Server, omit `/graphspaces/DEFAULT` from the path.
+
```bash
-> curl "http://localhost:8080/graphs/hugegraph/graph/vertices" | gunzip
+curl --compressed "http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices"
{"vertices":[{"id":1,"label":"software","type":"vertex","properties":{"name":"lop","lang":"java","price":328.0}},{"id":2,"label":"software","type":"vertex","properties":{"name":"ripple","lang":"java","price":199.0}},{"id":"1:tom","label":"person","type":"vertex","properties":{"name":"tom"}},{"id":"1:josh","label":"person","type":"vertex","properties":{"name":"josh","age":32,"city":"Beijing"}},{"id":"1:marko","label":"person","type":"vertex","properties":{"name":"marko","age":29,"city":"B [...]
```
-If you want to check the import result of edges, you can use `curl "http://localhost:8080/graphs/hugegraph/graph/edges" | gunzip`.
+If you want to check the import result of edges, you can use `curl --compressed "http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges"`.
##### 4.5.2 Enter the docker container to load data