GitHub user dosubot[bot] edited a comment on the discussion: 关于电网拓扑数据导入
<!-- Answer -->
你的 value_mapping 写法是对的,但你的配置还有两个关键点需要修正,否则边会全部插入失败:
1. **field_mapping 只写 from/to,不要写 id**
struct.json 的 edges 里 field_mapping 应该这样写:
```json
"field_mapping": { "from": "id", "to": "id" }
```
不要把 id 字段导入为边属性,除非 edgeLabel 的 .properties() 里有 id(绝大多数场景不需要)。
2. **schema.groovy 的 edgeLabel .properties() 只写 source_label、target_label,不要加
id**
比如:
```groovy
schema.edgeLabel("LineSegment2LineSegment")
.sourceLabel("LineSegment")
.targetLabel("LineSegment")
.properties("source_label", "target_label")
.ifNotExist().create();
```
不要写 .properties("id", "source_label", "target_label"),否则 loader 会报 “Invalid
property 'id' for edge label”。
3. **value_mapping 必须是平铺结构**
你的写法没问题,保持这样:
```json
"value_mapping": {
"label": { "CONNECTED_TO": "LineSegment2LineSegment" },
"source_label": { "LineSegment": "LineSegment" },
"target_label": { "LineSegment": "LineSegment" }
}
```
4. **edge_connected_to.csv 的 source_label/target_label 必须和顶点 label
完全一致(区分大小写)**
比如 from=XLD-3445 在 vertex_linesegment-1.csv 里,label 是 LineSegment,就写
LineSegment。
**最终检查清单:**
- edgeLabel 的 .properties() 只包含 "source_label", "target_label",不要加 "id"
- struct.json 的 field_mapping 只写 from/to,不要写 id
- value_mapping 是平铺结构
- edge_connected_to.csv 的 source_label/target_label 和顶点 label 完全一致
这样配置后,边就能正常导入且无报错,所有关系都能导入。详细机制见[官方文档](https://github.com/apache/incubator-hugegraph-doc/blob/3e1c610281c91ea3a5c600b393088e9ffae34799/content/en/docs/quickstart/toolchain/hugegraph-loader.md#L705-L1064)。
如还有具体报错,可以贴出 struct.json/schema.groovy/CSV 的片段,我可以帮你逐条检查。
<!-- Dosu Comment Footer -->
*To reply, just mention
[@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=reply-with-mention&utm_term=apache%2Fhugegraph).*
---
Share context across your team and agents. Try
[Dosu](https://dosu.dev?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-tagline&utm_term=apache%2Fhugegraph).
[](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-feedback&utm_term=apache%2Fhugegraph#message_id=002bb7c6-7904-43a3-803d-83cf5c55dcdc)
[](https://github.dosu.com/apache/hugegraph?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-learn-repo&utm_term=apache%2Fhugegraph)
[](https://app.dosu.dev/signup?referrer=openSource&source=github-footer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-add-team&utm_term=apache%2Fhugegraph)
GitHub link:
https://github.com/apache/hugegraph/discussions/2917#discussioncomment-15205562
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]