GitHub user dosubot[bot] added a comment to 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).*
---
<sup>How did I do?
[Good](https://app.dosu.dev/response-feedback/002bb7c6-7904-43a3-803d-83cf5c55dcdc?feedback_type=great_response)
|
[Irrelevant](https://app.dosu.dev/response-feedback/002bb7c6-7904-43a3-803d-83cf5c55dcdc?feedback_type=irrelevant_answer)
|
[Incorrect](https://app.dosu.dev/response-feedback/002bb7c6-7904-43a3-803d-83cf5c55dcdc?feedback_type=incorrect_sources)
|
[Verbose](https://app.dosu.dev/response-feedback/002bb7c6-7904-43a3-803d-83cf5c55dcdc?feedback_type=too_verbose)
|
[Hallucination](https://app.dosu.dev/response-feedback/002bb7c6-7904-43a3-803d-83cf5c55dcdc?feedback_type=hallucination)
| [Report
🐛](https://app.dosu.dev/response-feedback/002bb7c6-7904-43a3-803d-83cf5c55dcdc?feedback_type=bug_report)
|
[Other](https://app.dosu.dev/response-feedback/002bb7c6-7904-43a3-803d-83cf5c55dcdc?feedback_type=other)</sup>
[](https://app.dosu.dev/e5e246fa-a522-4d8a-ab3c-e2588b5b501b/ask?utm_source=github) [](https://cursor.com/link/prompt?text=%E4%BD%A0%E7%9A%84%20value_mapping%20%E5%86%99%E6%B3%95%E6%98%AF%E5%AF%B9%E7%9A%84%EF%BC%8C%E4%BD%86%E4%BD%A0%E7%9A%84%E9%85%8D%E7%BD%AE%E8%BF%98%E6%9C%89%E4%B8%A4%E4%B8%AA%E5%85%B3%E9%94%AE%E7%82%B9%E9%9C%80%E8%A6%81%E4%BF%AE%E6%AD%A3%EF%BC%8C%E5%90%A6%E5%88%99%E8%BE%B9%E4%BC%9A%E5%85%A8%E9%83%A8%E6%8F%92%E5%85%A5%E5%A4%B1%E8%B4%A5%EF%BC%9A%0A%0A1.%20%2A%2Afield_mapping%20%E5%8F%AA%E5%86%99%20from/to%EF%BC%8C%E4%B8%8D%E8%A6%81%E5%86%99%20id%2A%2A%20%20%0Astruct.json%20%E7%9A%84%20edges%20%E9%87%8C%20field_mapping%20%E5%BA%94%E8%AF%A5%E8%BF%99%E6%A0%B7%E5%86%99%EF%BC%9A%0A%60%60%60json%0A%22field_mapping%22%3A%20%7B%20%22from%22%3A%20%22id%22%2C%20%22to%22%3A%20%22id%22%20%7D%0A%60%60%60%0A%E4%B8%8D%E8%A6%81%E6%8A%8A%20id%20%E5%AD%97%E6%AE%B5%E5%AF%BC
%E5%85%A5%E4%B8%BA%E8%BE%B9%E5%B1%9E%E6%80%A7%EF%BC%8C%E9%99%A4%E9%9D%9E%20edgeLabel%20%E7%9A%84%20.properties%28%29%20%E9%87%8C%E6%9C%89%20id%EF%BC%88%E7%BB%9D%E5%A4%A7%E5%A4%9A%E6%95%B0%E5%9C%BA%E6%99%AF%E4%B8%8D%E9%9C%80%E8%A6%81%EF%BC%89%E3%80%82%0A%0A2.%20%2A%2Aschema.groovy%20%E7%9A%84%20edgeLabel%20.properties%28%29%20%E5%8F%AA%E5%86%99%20source_label%E3%80%81target_label%EF%BC%8C%E4%B8%8D%E8%A6%81%E5%8A%A0%20id%2A%2A%20%20%0A%E6%AF%94%E5%A6%82%EF%BC%9A%0A%60%60%60groovy%0Aschema.edgeLabel%28%22LineSegment2LineSegment%22%29%0A%20%20%20%20.sourceLabel%28%22LineSegment%22%29%0A%20%20%20%20.targetLabel%28%22LineSegment%22%29%0A%20%20%20%20.properties%28%22source_label%22%2C%20%22target_label%22%29%0A%20%20%20%20.ifNotExist%28%29.create%28%29%3B%0A%60%60%60%0A%E4%B8%8D%E8%A6%81%E5%86%99%20.properties%28%22id%22%2C%20%22source_label%22%2C%20%22target_label%22%29%EF%BC%8C%E5%90%A6%E5%88%99%20loader%20%E4%BC%9A%E6%8A%A5%20%E2%80%9CInvalid%20property%20%27id%27%20for%20edge%20label%E
2%80%9D%E3%80%82%0A%0A3.%20%2A%2Avalue_mapping%20%E5%BF%85%E9%A1%BB%E6%98%AF%E5%B9%B3%E9%93%BA%E7%BB%93%E6%9E%84%2A%2A%20%20%0A%E4%BD%A0%E7%9A%84%E5%86%99%E6%B3%95%E6%B2%A1%E9%97%AE%E9%A2%98%EF%BC%8C%E4%BF%9D%E6%8C%81%E8%BF%99%E6%A0%B7%EF%BC%9A%0A%60%60%60json%0A%22value_mapping%22%3A%20%7B%0A%20%20%22label%22%3A%20%7B%20%22CONNECTED_TO%22%3A%20%22LineSegment2LineSegment%22%20%7D%2C%0A%20%20%22source_label%22%3A%20%7B%20%22LineSegment%22%3A%20%22LineSegment%22%20%7D%2C%0A%20%20%22target_label%22%3A%20%7B%20%22LineSegment%22%3A%20%22LineSegment%22%20%7D%0A%7D%0A%60%60%60%0A%0A4.%20%2A%2Aedge_connected_to.csv%20%E7%9A%84%20source_label/target_label%20%E5%BF%85%E9%A1%BB%E5%92%8C%E9%A1%B6%E7%82%B9%20label%20%E5%AE%8C%E5%85%A8%E4%B8%80%E8%87%B4%EF%BC%88%E5%8C%BA%E5%88%86%E5%A4%A7%E5%B0%8F%E5%86%99%EF%BC%89%2A%2A%20%20%0A%E6%AF%94%E5%A6%82%20from%3DXLD-3445%20%E5%9C%A8%20vertex_linesegment-1.csv%20%E9%87%8C%EF%BC%8Clabel%20%E6%98%AF%20LineSegment%EF%BC%8C%E5%B0%B1%E5%86%99%20LineSegment%E
3%80%82%0A%0A%2A%2A%E6%9C%80%E7%BB%88%E6%A3%80%E6%9F%A5%E6%B8%85%E5%8D%95%EF%BC%9A%2A%2A%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%0A-%20struct.json%20%E7%9A%84%20field_mapping%20%E5%8F%AA%E5%86%99%20from/to%EF%BC%8C%E4%B8%8D%E8%A6%81%E5%86%99%20id%0A-%20value_mapping%20%E6%98%AF%E5%B9%B3%E9%93%BA%E7%BB%93%E6%9E%84%0A-%20edge_connected_to.csv%20%E7%9A%84%20source_label/target_label%20%E5%92%8C%E9%A1%B6%E7%82%B9%20label%20%E5%AE%8C%E5%85%A8%E4%B8%80%E8%87%B4%0A%0A%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%E8%AF%A6%E7%BB%86%E6%9C%BA%E5%88%B6%E8%A7%81%5B%E5%AE%98%E6%96%B9%E6%96%87%E6%A1%A3%5D%28https%3A//github.com/apache/incubator-hugegraph-doc/blob/3e1c610281c9
1ea3a5c600b393088e9ffae34799/content/en/docs/quickstart/toolchain/hugegraph-loader.md%23L705-L1064%29%E3%80%82%0A%0A%E5%A6%82%E8%BF%98%E6%9C%89%E5%85%B7%E4%BD%93%E6%8A%A5%E9%94%99%EF%BC%8C%E5%8F%AF%E4%BB%A5%E8%B4%B4%E5%87%BA%20struct.json/schema.groovy/CSV%20%E7%9A%84%E7%89%87%E6%AE%B5%EF%BC%8C%E6%88%91%E5%8F%AF%E4%BB%A5%E5%B8%AE%E4%BD%A0%E9%80%90%E6%9D%A1%E6%A3%80%E6%9F%A5%E3%80%82) [](https://go.dosu.dev/discord-bot) [](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-15205562
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]