GitHub user dosubot[bot] edited a comment on the discussion: 关于电网拓扑数据导入
<!-- Answer -->
你只需要在 schema.groovy 里加上这两行即可解决 “属性键'source_label'不存在” 的报错:
```groovy
schema.propertyKey("source_label").asText().ifNotExist().create();
schema.propertyKey("target_label").asText().ifNotExist().create();
```
建议把这两行放在所有 propertyKey 定义的部分(和 id、name 等属性一起)。这样 loader 才能识别 struct.json 和
edge_connected_to.csv 里的 source_label、target_label 字段。
如果你希望把 source_label 和 target_label 作为边的属性存储(可选),可以在相关 edgeLabel 的 .properties()
里加上这两个属性,比如:
```groovy
schema.edgeLabel("LineSegment2StationHouse")
.sourceLabel("LineSegment")
.targetLabel("StationHouse")
.properties("source_label", "target_label")
.ifNotExist().create();
```
注意事项:
- edge_connected_to.csv 的 source_label/target_label 列内容必须和 schema.groovy 里顶点
label 完全一致(区分大小写),比如 LineSegment、StationHouse、LineSwitch、Substation。
- struct.json 的 value_mapping 要是平铺结构,不要嵌套在 label 下面,应该是:
```json
"value_mapping": {
"label": { "CONNECTED_TO": "LineSegment2StationHouse" },
"source_label": { "LineSegment": "LineSegment" },
"target_label": { "StationHouse": "StationHouse" }
}
```
- 修改 schema 后,重新执行 schema 创建和数据导入流程。
官方文档有详细说明:[schema.propertyKey
定义示例](https://github.com/apache/incubator-hugegraph-doc/blob/3e1c610281c91ea3a5c600b393088e9ffae34799/content/en/docs/quickstart/toolchain/hugegraph-loader.md#L897-L1100)
如还有问题,可以贴出 struct.json、schema.groovy 和 edge_connected_to.csv 的片段,我可以帮你逐条检查。
<!-- 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=8d940d65-8081-4ff5-a3b8-edb36aabc995)
[](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-15204714
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]