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

---
<sup>How did I do? 
[Good](https://app.dosu.dev/response-feedback/1a6c86d3-0fd3-44b7-82dc-c06d4d5cd869?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/1a6c86d3-0fd3-44b7-82dc-c06d4d5cd869?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/1a6c86d3-0fd3-44b7-82dc-c06d4d5cd869?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/1a6c86d3-0fd3-44b7-82dc-c06d4d5cd869?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/1a6c86d3-0fd3-44b7-82dc-c06d4d5cd869?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/1a6c86d3-0fd3-44b7-82dc-c06d4d5cd869?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/1a6c86d3-0fd3-44b7-82dc-c06d4d5cd869?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%E9%85%8D%E7%BD%AE%E5%8F%AA%E5%B7%AE%E4%B8%80%E4%B8%AA%E5%85%B3%E9%94%AE%E7%82%B9%E5%B0%B1%E8%83%BD%E5%AF%BC%E5%85%A5%E6%88%90%E5%8A%9F%EF%BC%9A%2A%2Astruct.json%20%E7%9A%84%20edges%20%E9%87%8C%20field_mapping%20%E5%BF%85%E9%A1%BB%E5%86%99%E6%88%90%2A%2A%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%60%7B%20%22from%22%3A%20%22id%22%2C%20%22to%22%3A%20%22id%22%20%7D%60%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%2A%2A%E8%AF%A6%E7%BB%86%E5%8E%9F%E5%9B%A0%E5%92%8C%E4%BF%AE%E6%AD%A3%E6%96%B9%E6%B3%95%EF%BC%9A%2A%2A%0A%0A-%20%E4%BD%A0%E7%9A%84%E9%A1%B6%E7%82%B9%E4%B8%BB%E9%94%AE%E6%98%AF%20id%EF%BC%88vertex_xxx.csv%20%E9%87%8C%E6%9C%89%20id%20%E5%88%97%EF%BC%8Cschema%20%E9%87%8C%20primaryKeys%28%22id%22%29%EF%BC%89%EF%BC%8Cloader%20%E5%8F%AA%E4%BC%9A%E7%94%A8%20from/to%20%E5%AD%97%E6%AE%B5%E7%9A%84%E5%80%BC%E7%9B%B4%E6%8E%A5%E4%BD%9C%E4%B8%BA%E9%A1%B6%E7%82%B9%E4%B8%BB%E9%94%AE%20id%EF%BC%8C%E4%B8%8D%E4%BC%9A%E5%86%8D%E5%8E%BB%E6%9F%A5%20vertex_xxx.csv%20%E7%9A%84%E5%85%B6%E4%BB%96%E5%AD%97%E6%AE%B5%E3%80%82%0A-%20edge_connected_to.csv%20%E7%9A%84%20id%20%E5%88%97%E5%8F%AF%E4%BB%A5%E4%BF%9D%E7%95%99%EF%BC%8C%E4%BD%86
 
%20loader%20%E4%B8%8D%E4%BC%9A%E5%AF%BC%E5%85%A5%E5%AE%83%E4%B8%BA%E8%BE%B9%E5%B1%9E%E6%80%A7%EF%BC%8C%E5%8F%AA%E8%A6%81%20field_mapping%20%E4%B8%8D%E5%86%99%20id%20%E5%B0%B1%E4%B8%8D%E4%BC%9A%E6%8A%A5%E9%94%99%E3%80%82%0A-%20edgeLabel%20%E7%9A%84%20.properties%28%29%20%E5%8F%AA%E5%8C%85%E5%90%AB%20%22source_label%22%2C%20%22target_label%22%EF%BC%8C%E4%B8%8D%E8%A6%81%E5%8A%A0%20%22id%22%E3%80%82%0A-%20value_mapping%20%E5%BF%85%E9%A1%BB%E6%98%AF%E5%B9%B3%E9%93%BA%E7%BB%93%E6%9E%84%EF%BC%88%E4%BD%A0%E7%8E%B0%E5%9C%A8%E7%9A%84%E5%86%99%E6%B3%95%E6%B2%A1%E9%97%AE%E9%A2%98%EF%BC%89%E3%80%82%0A-%20null_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%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%0A%0A%2A%2A%E4%BD%A0%E5%8F%AA%E9%9C%80%E8%A6%81%E6%8A%8A%20struct.json%20%E9%87%8C%E6%89%80%E6%9C%89%20edges%20%E7%9A%84%20field_mappi
 
ng%20%E5%85%A8%E9%83%A8%E6%94%B9%E6%88%90%EF%BC%9A%2A%2A%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%E5%85%B6%E4%BB%96%E9%85%8D%E7%BD%AE%E4%B8%8D%E7%94%A8%E5%8A%A8%E3%80%82%E8%BF%99%E6%A0%B7%E9%85%8D%E7%BD%AE%E5%90%8E%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%0A%0A%E5%A6%82%E6%9E%9C%E8%BF%98%E6%9C%89%E6%8A%A5%E9%94%99%EF%BC%8C%E8%AF%B7%E8%B4%B4%E5%87%BA%20power_edges_to.csv%20%E7%9A%84%20header%20%E5%92%8C%E5%89%8D%E5%87%A0%E8%A1%8C%E5%8E%9F%E5%A7%8B%E6%95%B0%E6%8D%AE%EF%BC%8C%E4%BB%A5%E5%8F%8A%20struct.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%E
 
F%BC%8C%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)&nbsp;[![Join
 
Discord](https://img.shields.io/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-15216007

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

Reply via email to