GitHub user dosubot[bot] edited a comment on the discussion: 关于电网拓扑数据导入
<!-- Answer -->
你的 struct_1.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] 为空” 的报错。
如果你已经这样写了但还是报错,**请务必检查以下几点**:
1. **source/target 配置必须是** `"source": ["from"], "target": ["to"]`,不能写反。
2. **field_mapping 必须是** `{ "from": "from", "to": "to" }`,不要有 id。
3. **CSV header 必须严格为** `id,from,to,label,source_label,target_label`,不能有多余空格或
BOM。
4. **所有 from/to 字段都不能有空值,且和顶点 id 完全一致**(无多余空格、无大小写问题、无空行)。
5. **null_values 建议只保留 ["NULL", "null"],不要加 ""**,否则空字符串会被判定为 null。
6. **schema.groovy 的边标签 .properties() 只包含实际需要的属性**(如 "source_label",
"target_label"),不要加 "id"。
如果你已经全部按上述做了,还是报 “Make sure the primary key fields [id] are not empty, or check
whether the headers or field_mapping are configured correctly”,请贴出:
- edge_connected_to.csv 的 header 和前 2 行原始数据(不要做任何处理)
- struct_1.json 某个 edges 配置的完整内容(尤其是 source/target/field_mapping/value_mapping)
这样我可以帮你定位具体是哪一行或哪一列有问题。
**常见坑:**
- source/target 写反了(比如 "source": ["to"], "target": ["from"])
- field_mapping 写成了 id
- CSV header 有隐藏字符或 BOM
- null_values 配置了空字符串
- 顶点 id 有重复或空行
只要这几点全部做到,边就能正常导入且无报错,所有关系都能导入。[官方FAQ说明](https://github.com/apache/incubator-hugegraph-doc/blob/master/content/en/docs/guides/faq.md)
<!-- 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=15f152d5-4894-4d82-9652-261e7b4708b5)
[](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-15226371
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]