GitHub user dosubot[bot] edited a comment on the discussion: 关于电网拓扑数据导入
<!-- Answer -->
你的配置只差一个关键点就能导入成功:**struct.json 的 edges 里 field_mapping 必须写成**:
```json
"field_mapping": { "from": "from", "to": "to" }
```
不能写成 `{ "from": "id", "to": "id" }`,否则 loader 会把 CSV 的 id 列当作边属性导入,但
schema.groovy 的 edgeLabel 没有声明 id 属性,导致 “Invalid property 'id' for edge label”
或 “主键字段 [id] 为空” 的报错。
**详细原因和修正方法:**
- 你的顶点主键是 id(vertex_xxx.csv 里有 id 列,schema 里 primaryKeys("id")),loader 只会用
from/to 字段的值直接作为顶点主键 id,不会再去查 vertex_xxx.csv 的其他字段。
- edge_connected_to.csv 的 id 列可以保留,但 loader 不会导入它为边属性,只要 field_mapping 不写 id
就不会报错。
- edgeLabel 的 .properties() 只包含 "source_label", "target_label",不要加 "id"。
- value_mapping 必须是平铺结构(你现在的写法没问题)。
- null_values 建议只保留 ["NULL", "null"],不要加 "",否则空字符串会被判定为 null。
**你只需要把 struct.json 里所有 edges 的 field_mapping 全部改成:**
```json
"field_mapping": { "from": "from", "to": "to" }
```
其他配置不用动。这样配置后,边就能正常导入且无报错,所有关系都能导入。[官方FAQ说明](https://github.com/apache/incubator-hugegraph-doc/blob/master/content/en/docs/guides/faq.md)
如果还有报错,请贴出 power_edges_to.csv 的 header 和前几行原始数据,以及 struct.json 某个 edges
配置的完整内容,我可以帮你定位具体是哪一行或哪一列有问题。
<!-- 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).*
---
Docs are dead. Just use
[Dosu](https://dosu.dev?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-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=static-docs-feedback&utm_term=apache%2Fhugegraph#message_id=1a6c86d3-0fd3-44b7-82dc-c06d4d5cd869)
[](https://github.dosu.com/apache/hugegraph?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-ask-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=static-docs-share-team&utm_term=apache%2Fhugegraph)
GitHub link:
https://github.com/apache/hugegraph/discussions/2917#discussioncomment-15216007
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]