GitHub user dosubot[bot] added a comment to 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).*

---
<sup>How did I do? 
[Good](https://app.dosu.dev/response-feedback/15f152d5-4894-4d82-9652-261e7b4708b5?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/15f152d5-4894-4d82-9652-261e7b4708b5?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/15f152d5-4894-4d82-9652-261e7b4708b5?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/15f152d5-4894-4d82-9652-261e7b4708b5?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/15f152d5-4894-4d82-9652-261e7b4708b5?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/15f152d5-4894-4d82-9652-261e7b4708b5?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/15f152d5-4894-4d82-9652-261e7b4708b5?feedback_type=other)</sup>

[![Chat with 
Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/e5e246fa-a522-4d8a-ab3c-e2588b5b501b/ask?utm_source=github)&nbsp;[![Open
 in 
Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=%E4%BD%A0%E7%9A%84%20struct_1.json%20%E9%87%8C%20edges%20%E7%9A%84%20field_mapping%20%E5%BF%85%E9%A1%BB%E5%86%99%E6%88%90%EF%BC%9A%0A%0A%60%60%60json%0A%22field_mapping%22%3A%20%7B%20%22from%22%3A%20%22from%22%2C%20%22to%22%3A%20%22to%22%20%7D%0A%60%60%60%0A%0A%E4%B8%8D%E8%83%BD%E5%86%99%E6%88%90%20%7B%20%22from%22%3A%20%22id%22%2C%20%22to%22%3A%20%22id%22%20%7D%EF%BC%8C%E5%90%A6%E5%88%99%20loader%20%E4%BC%9A%E6%8A%8A%20CSV%20%E7%9A%84%20id%20%E5%88%97%E5%BD%93%E4%BD%9C%E8%BE%B9%E5%B1%9E%E6%80%A7%E5%AF%BC%E5%85%A5%EF%BC%8C%E4%BD%86%20schema.groovy%20%E7%9A%84%20edgeLabel%20%E6%B2%A1%E6%9C%89%E5%A3%B0%E6%98%8E%20id%20%E5%B1%9E%E6%80%A7%EF%BC%8C%E5%AF%BC%E8%87%B4%20%E2%80%9CInvalid%20property%20%27id%27%20for%20edge%20label%E2%80%9D%20%E6%88%96%20%E2%80
 
%9C%E4%B8%BB%E9%94%AE%E5%AD%97%E6%AE%B5%20%5Bid%5D%20%E4%B8%BA%E7%A9%BA%E2%80%9D%20%E7%9A%84%E6%8A%A5%E9%94%99%E3%80%82%0A%0A%E5%A6%82%E6%9E%9C%E4%BD%A0%E5%B7%B2%E7%BB%8F%E8%BF%99%E6%A0%B7%E5%86%99%E4%BA%86%E4%BD%86%E8%BF%98%E6%98%AF%E6%8A%A5%E9%94%99%EF%BC%8C%2A%2A%E8%AF%B7%E5%8A%A1%E5%BF%85%E6%A3%80%E6%9F%A5%E4%BB%A5%E4%B8%8B%E5%87%A0%E7%82%B9%2A%2A%EF%BC%9A%0A%0A1.%20%2A%2Asource/target%20%E9%85%8D%E7%BD%AE%E5%BF%85%E9%A1%BB%E6%98%AF%2A%2A%20%60%22source%22%3A%20%5B%22from%22%5D%2C%20%22target%22%3A%20%5B%22to%22%5D%60%EF%BC%8C%E4%B8%8D%E8%83%BD%E5%86%99%E5%8F%8D%E3%80%82%0A2.%20%2A%2Afield_mapping%20%E5%BF%85%E9%A1%BB%E6%98%AF%2A%2A%20%60%7B%20%22from%22%3A%20%22from%22%2C%20%22to%22%3A%20%22to%22%20%7D%60%EF%BC%8C%E4%B8%8D%E8%A6%81%E6%9C%89%20id%E3%80%82%0A3.%20%2A%2ACSV%20header%20%E5%BF%85%E9%A1%BB%E4%B8%A5%E6%A0%BC%E4%B8%BA%2A%2A%20%60id%2Cfrom%2Cto%2Clabel%2Csource_label%2Ctarget_label%60%EF%BC%8C%E4%B8%8D%E8%83%BD%E6%9C%89%E5%A4%9A%E4%BD%99%E7%A9%BA%E6%A0%BC%E6%88%96%20BOM
 
%E3%80%82%0A4.%20%2A%2A%E6%89%80%E6%9C%89%20from/to%20%E5%AD%97%E6%AE%B5%E9%83%BD%E4%B8%8D%E8%83%BD%E6%9C%89%E7%A9%BA%E5%80%BC%EF%BC%8C%E4%B8%94%E5%92%8C%E9%A1%B6%E7%82%B9%20id%20%E5%AE%8C%E5%85%A8%E4%B8%80%E8%87%B4%2A%2A%EF%BC%88%E6%97%A0%E5%A4%9A%E4%BD%99%E7%A9%BA%E6%A0%BC%E3%80%81%E6%97%A0%E5%A4%A7%E5%B0%8F%E5%86%99%E9%97%AE%E9%A2%98%E3%80%81%E6%97%A0%E7%A9%BA%E8%A1%8C%EF%BC%89%E3%80%82%0A5.%20%2A%2Anull_values%20%E5%BB%BA%E8%AE%AE%E5%8F%AA%E4%BF%9D%E7%95%99%20%5B%22NULL%22%2C%20%22null%22%5D%EF%BC%8C%E4%B8%8D%E8%A6%81%E5%8A%A0%20%22%22%2A%2A%EF%BC%8C%E5%90%A6%E5%88%99%E7%A9%BA%E5%AD%97%E7%AC%A6%E4%B8%B2%E4%BC%9A%E8%A2%AB%E5%88%A4%E5%AE%9A%E4%B8%BA%20null%E3%80%82%0A6.%20%2A%2Aschema.groovy%20%E7%9A%84%E8%BE%B9%E6%A0%87%E7%AD%BE%20.properties%28%29%20%E5%8F%AA%E5%8C%85%E5%90%AB%E5%AE%9E%E9%99%85%E9%9C%80%E8%A6%81%E7%9A%84%E5%B1%9E%E6%80%A7%2A%2A%EF%BC%88%E5%A6%82%20%22source_label%22%2C%20%22target_label%22%EF%BC%89%EF%BC%8C%E4%B8%8D%E8%A6%81%E5%8A%A0%20%22id%22%E3%80%82%0A%0A%E5
 
%A6%82%E6%9E%9C%E4%BD%A0%E5%B7%B2%E7%BB%8F%E5%85%A8%E9%83%A8%E6%8C%89%E4%B8%8A%E8%BF%B0%E5%81%9A%E4%BA%86%EF%BC%8C%E8%BF%98%E6%98%AF%E6%8A%A5%20%E2%80%9CMake%20sure%20the%20primary%20key%20fields%20%5Bid%5D%20are%20not%20empty%2C%20or%20check%20whether%20the%20headers%20or%20field_mapping%20are%20configured%20correctly%E2%80%9D%EF%BC%8C%E8%AF%B7%E8%B4%B4%E5%87%BA%EF%BC%9A%0A%0A-%20edge_connected_to.csv%20%E7%9A%84%20header%20%E5%92%8C%E5%89%8D%202%20%E8%A1%8C%E5%8E%9F%E5%A7%8B%E6%95%B0%E6%8D%AE%EF%BC%88%E4%B8%8D%E8%A6%81%E5%81%9A%E4%BB%BB%E4%BD%95%E5%A4%84%E7%90%86%EF%BC%89%0A-%20struct_1.json%20%E6%9F%90%E4%B8%AA%20edges%20%E9%85%8D%E7%BD%AE%E7%9A%84%E5%AE%8C%E6%95%B4%E5%86%85%E5%AE%B9%EF%BC%88%E5%B0%A4%E5%85%B6%E6%98%AF%20source/target/field_mapping/value_mapping%EF%BC%89%0A%0A%E8%BF%99%E6%A0%B7%E6%88%91%E5%8F%AF%E4%BB%A5%E5%B8%AE%E4%BD%A0%E5%AE%9A%E4%BD%8D%E5%85%B7%E4%BD%93%E6%98%AF%E5%93%AA%E4%B8%80%E8%A1%8C%E6%88%96%E5%93%AA%E4%B8%80%E5%88%97%E6%9C%89%E9%97%AE%E9%A2%98%E3%80%82
 
%0A%0A%2A%2A%E5%B8%B8%E8%A7%81%E5%9D%91%EF%BC%9A%2A%2A%0A-%20source/target%20%E5%86%99%E5%8F%8D%E4%BA%86%EF%BC%88%E6%AF%94%E5%A6%82%20%22source%22%3A%20%5B%22to%22%5D%2C%20%22target%22%3A%20%5B%22from%22%5D%EF%BC%89%0A-%20field_mapping%20%E5%86%99%E6%88%90%E4%BA%86%20id%0A-%20CSV%20header%20%E6%9C%89%E9%9A%90%E8%97%8F%E5%AD%97%E7%AC%A6%E6%88%96%20BOM%0A-%20null_values%20%E9%85%8D%E7%BD%AE%E4%BA%86%E7%A9%BA%E5%AD%97%E7%AC%A6%E4%B8%B2%0A-%20%E9%A1%B6%E7%82%B9%20id%20%E6%9C%89%E9%87%8D%E5%A4%8D%E6%88%96%E7%A9%BA%E8%A1%8C%0A%0A%E5%8F%AA%E8%A6%81%E8%BF%99%E5%87%A0%E7%82%B9%E5%85%A8%E9%83%A8%E5%81%9A%E5%88%B0%EF%BC%8C%E8%BE%B9%E5%B0%B1%E8%83%BD%E6%AD%A3%E5%B8%B8%E5%AF%BC%E5%85%A5%E4%B8%94%E6%97%A0%E6%8A%A5%E9%94%99%EF%BC%8C%E6%89%80%E6%9C%89%E5%85%B3%E7%B3%BB%E9%83%BD%E8%83%BD%E5%AF%BC%E5%85%A5%E3%80%82%5B%E5%AE%98%E6%96%B9FAQ%E8%AF%B4%E6%98%8E%5D%28https%3A//github.com/apache/incubator-hugegraph-doc/blob/master/content/en/docs/guides/faq.md%29)&nbsp;[![Join
 Discord](https://img.shields.i
 
o/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share
 on 
X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/incubator-hugegraph/discussions/2917)

GitHub link: 
https://github.com/apache/incubator-hugegraph/discussions/2917#discussioncomment-15226371

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]

Reply via email to