GitHub user dosubot[bot] added a comment to the discussion: 关于电网拓扑数据导入
<!-- Answer --> 你的 struct.json 和 schema.groovy 配置思路是对的,但要确保所有连接关系都能导入,必须做到以下几点: 1. edge_connected_to.csv 必须有 source_label 和 target_label 两列,并且内容要和 schema.groovy 里顶点的 label 完全一致(比如 LineSegment、StationHouse、LineSwitch、Substation 等),否则边会被跳过但不会报错([官方文档说明](https://github.com/apache/incubator-hugegraph-doc/blob/3e1c610281c91ea3a5c600b393088e9ffae34799/content/en/docs/quickstart/toolchain/hugegraph-loader.md#L139-L1100))。 2. struct.json 里每个 edgeLabel(比如 Substation2LineSegment、LineSegment2StationHouse、LineSegment2LineSegment、LineSegment2LineSwitch、LineSwitch2LineSegment、StationHouse2LineSwitch、LineSwitch2StationHouse 等)都要写一段,value_mapping 里的 label/source_label/target_label 必须和 schema.groovy 里的 edgeLabel、sourceLabel、targetLabel 完全一致。 3. 你的 edge_connected_to.csv 目前只有 from、to、label,没有 source_label/target_label,建议用脚本或 Excel 增加这两列,内容要和 from/to 对应的顶点类型一致(比如 from=XLD-3445 就查 vertex_linesegment-1.csv,类型是 LineSegment)。 4. 只有这样,struct.json 的 value_mapping 才能精确筛选属于自己的那部分边,否则 loader 会尝试导入所有行,但只有 label、source_label、target_label 都匹配 schema 才会真正导入,其他会被静默跳过。 5. 导入后建议用 REST API 查询各类边的数量和类型,确认所有关系都齐全。 举例(以 LineSegment2StationHouse 为例): ```json { "label": "LineSegment2StationHouse", "source": ["from"], "target": ["to"], "input": { "type": "file", "path": "/loader/power_data/edge_connected_to.csv", "format": "CSV", "header": ["id", "from", "to", "label", "source_label", "target_label"] }, "field_mapping": { "from": "id", "to": "id" }, "value_mapping": { "label": { "CONNECTED_TO": "LineSegment2StationHouse" }, "source_label": { "LineSegment": "LineSegment" }, "target_label": { "StationHouse": "StationHouse" } } } ``` 每种类型的边都要写一段,path 可以都指向同一个 CSV 文件。 **建议你先检查 edge_connected_to.csv 是否有 source_label/target_label 字段,且内容和顶点 label 一致,再检查 struct.json 里每个 edgeLabel 的 value_mapping 是否和 schema.groovy 完全一致。** 如还有问题,可以贴出一小段 edge_connected_to.csv(含 source_label/target_label)和 struct.json 的完整 edge 配置,我可以帮你逐条检查。 <!-- 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/dc658f2e-02bd-4ab1-abab-01afe84e26ff?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/dc658f2e-02bd-4ab1-abab-01afe84e26ff?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/dc658f2e-02bd-4ab1-abab-01afe84e26ff?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/dc658f2e-02bd-4ab1-abab-01afe84e26ff?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/dc658f2e-02bd-4ab1-abab-01afe84e26ff?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/dc658f2e-02bd-4ab1-abab-01afe84e26ff?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/dc658f2e-02bd-4ab1-abab-01afe84e26ff?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%20struct.json%20%E5%92%8C%20schema.groovy%20%E9%85%8D%E7%BD%AE%E6%80%9D%E8%B7%AF%E6%98%AF%E5%AF%B9%E7%9A%84%EF%BC%8C%E4%BD%86%E8%A6%81%E7%A1%AE%E4%BF%9D%E6%89%80%E6%9C%89%E8%BF%9E%E6%8E%A5%E5%85%B3%E7%B3%BB%E9%83%BD%E8%83%BD%E5%AF%BC%E5%85%A5%EF%BC%8C%E5%BF%85%E9%A1%BB%E5%81%9A%E5%88%B0%E4%BB%A5%E4%B8%8B%E5%87%A0%E7%82%B9%EF%BC%9A%0A%0A1.%20edge_connected_to.csv%20%E5%BF%85%E9%A1%BB%E6%9C%89%20source_label%20%E5%92%8C%20target_label%20%E4%B8%A4%E5%88%97%EF%BC%8C%E5%B9%B6%E4%B8%94%E5%86%85%E5%AE%B9%E8%A6%81%E5%92%8C%20schema.groovy%20%E9%87%8C%E9%A1%B6%E7%82%B9%E7%9A%84%20label%20%E5%AE%8C%E5%85%A8%E4%B8%80%E8%87%B4%EF%BC%88%E6%AF%94%E5%A6%82%20LineSegment%E3%80%81StationHouse%E3%80%81LineSwitch%E3%80%81Substation%20%E7%AD%89%EF%BC%8 9%EF%BC%8C%E5%90%A6%E5%88%99%E8%BE%B9%E4%BC%9A%E8%A2%AB%E8%B7%B3%E8%BF%87%E4%BD%86%E4%B8%8D%E4%BC%9A%E6%8A%A5%E9%94%99%EF%BC%88%5B%E5%AE%98%E6%96%B9%E6%96%87%E6%A1%A3%E8%AF%B4%E6%98%8E%5D%28https%3A//github.com/apache/incubator-hugegraph-doc/blob/3e1c610281c91ea3a5c600b393088e9ffae34799/content/en/docs/quickstart/toolchain/hugegraph-loader.md%23L139-L1100%29%EF%BC%89%E3%80%82%0A%0A2.%20struct.json%20%E9%87%8C%E6%AF%8F%E4%B8%AA%20edgeLabel%EF%BC%88%E6%AF%94%E5%A6%82%20Substation2LineSegment%E3%80%81LineSegment2StationHouse%E3%80%81LineSegment2LineSegment%E3%80%81LineSegment2LineSwitch%E3%80%81LineSwitch2LineSegment%E3%80%81StationHouse2LineSwitch%E3%80%81LineSwitch2StationHouse%20%E7%AD%89%EF%BC%89%E9%83%BD%E8%A6%81%E5%86%99%E4%B8%80%E6%AE%B5%EF%BC%8Cvalue_mapping%20%E9%87%8C%E7%9A%84%20label/source_label/target_label%20%E5%BF%85%E9%A1%BB%E5%92%8C%20schema.groovy%20%E9%87%8C%E7%9A%84%20edgeLabel%E3%80%81sourceLabel%E3%80%81targetLabel%20%E5%AE%8C%E5%85%A8%E4%B8%80%E8%87%B4%E3%80%82%0 A%0A3.%20%E4%BD%A0%E7%9A%84%20edge_connected_to.csv%20%E7%9B%AE%E5%89%8D%E5%8F%AA%E6%9C%89%20from%E3%80%81to%E3%80%81label%EF%BC%8C%E6%B2%A1%E6%9C%89%20source_label/target_label%EF%BC%8C%E5%BB%BA%E8%AE%AE%E7%94%A8%E8%84%9A%E6%9C%AC%E6%88%96%20Excel%20%E5%A2%9E%E5%8A%A0%E8%BF%99%E4%B8%A4%E5%88%97%EF%BC%8C%E5%86%85%E5%AE%B9%E8%A6%81%E5%92%8C%20from/to%20%E5%AF%B9%E5%BA%94%E7%9A%84%E9%A1%B6%E7%82%B9%E7%B1%BB%E5%9E%8B%E4%B8%80%E8%87%B4%EF%BC%88%E6%AF%94%E5%A6%82%20from%3DXLD-3445%20%E5%B0%B1%E6%9F%A5%20vertex_linesegment-1.csv%EF%BC%8C%E7%B1%BB%E5%9E%8B%E6%98%AF%20LineSegment%EF%BC%89%E3%80%82%0A%0A4.%20%E5%8F%AA%E6%9C%89%E8%BF%99%E6%A0%B7%EF%BC%8Cstruct.json%20%E7%9A%84%20value_mapping%20%E6%89%8D%E8%83%BD%E7%B2%BE%E7%A1%AE%E7%AD%9B%E9%80%89%E5%B1%9E%E4%BA%8E%E8%87%AA%E5%B7%B1%E7%9A%84%E9%82%A3%E9%83%A8%E5%88%86%E8%BE%B9%EF%BC%8C%E5%90%A6%E5%88%99%20loader%20%E4%BC%9A%E5%B0%9D%E8%AF%95%E5%AF%BC%E5%85%A5%E6%89%80%E6%9C%89%E8%A1%8C%EF%BC%8C%E4%BD%86%E5%8F%AA%E6%9C%89%20label%E3%80%81sour ce_label%E3%80%81target_label%20%E9%83%BD%E5%8C%B9%E9%85%8D%20schema%20%E6%89%8D%E4%BC%9A%E7%9C%9F%E6%AD%A3%E5%AF%BC%E5%85%A5%EF%BC%8C%E5%85%B6%E4%BB%96%E4%BC%9A%E8%A2%AB%E9%9D%99%E9%BB%98%E8%B7%B3%E8%BF%87%E3%80%82%0A%0A5.%20%E5%AF%BC%E5%85%A5%E5%90%8E%E5%BB%BA%E8%AE%AE%E7%94%A8%20REST%20API%20%E6%9F%A5%E8%AF%A2%E5%90%84%E7%B1%BB%E8%BE%B9%E7%9A%84%E6%95%B0%E9%87%8F%E5%92%8C%E7%B1%BB%E5%9E%8B%EF%BC%8C%E7%A1%AE%E8%AE%A4%E6%89%80%E6%9C%89%E5%85%B3%E7%B3%BB%E9%83%BD%E9%BD%90%E5%85%A8%E3%80%82%0A%0A%E4%B8%BE%E4%BE%8B%EF%BC%88%E4%BB%A5%20LineSegment2StationHouse%20%E4%B8%BA%E4%BE%8B%EF%BC%89%EF%BC%9A%0A%0A%60%60%60json%0A%7B%0A%20%20%22label%22%3A%20%22LineSegment2StationHouse%22%2C%0A%20%20%22source%22%3A%20%5B%22from%22%5D%2C%0A%20%20%22target%22%3A%20%5B%22to%22%5D%2C%0A%20%20%22input%22%3A%20%7B%0A%20%20%20%20%22type%22%3A%20%22file%22%2C%0A%20%20%20%20%22path%22%3A%20%22/loader/power_data/edge_connected_to.csv%22%2C%0A%20%20%20%20%22format%22%3A%20%22CSV%22%2C%0A%20%20%20%20%22heade r%22%3A%20%5B%22id%22%2C%20%22from%22%2C%20%22to%22%2C%20%22label%22%2C%20%22source_label%22%2C%20%22target_label%22%5D%0A%20%20%7D%2C%0A%20%20%22field_mapping%22%3A%20%7B%20%22from%22%3A%20%22id%22%2C%20%22to%22%3A%20%22id%22%20%7D%2C%0A%20%20%22value_mapping%22%3A%20%7B%0A%20%20%20%20%22label%22%3A%20%7B%20%22CONNECTED_TO%22%3A%20%22LineSegment2StationHouse%22%20%7D%2C%0A%20%20%20%20%22source_label%22%3A%20%7B%20%22LineSegment%22%3A%20%22LineSegment%22%20%7D%2C%0A%20%20%20%20%22target_label%22%3A%20%7B%20%22StationHouse%22%3A%20%22StationHouse%22%20%7D%0A%20%20%7D%0A%7D%0A%60%60%60%0A%0A%E6%AF%8F%E7%A7%8D%E7%B1%BB%E5%9E%8B%E7%9A%84%E8%BE%B9%E9%83%BD%E8%A6%81%E5%86%99%E4%B8%80%E6%AE%B5%EF%BC%8Cpath%20%E5%8F%AF%E4%BB%A5%E9%83%BD%E6%8C%87%E5%90%91%E5%90%8C%E4%B8%80%E4%B8%AA%20CSV%20%E6%96%87%E4%BB%B6%E3%80%82%0A%0A%2A%2A%E5%BB%BA%E8%AE%AE%E4%BD%A0%E5%85%88%E6%A3%80%E6%9F%A5%20edge_connected_to.csv%20%E6%98%AF%E5%90%A6%E6%9C%89%20source_label/target_label%20%E5%AD%97%E6%AE%B5%EF%BC%8C %E4%B8%94%E5%86%85%E5%AE%B9%E5%92%8C%E9%A1%B6%E7%82%B9%20label%20%E4%B8%80%E8%87%B4%EF%BC%8C%E5%86%8D%E6%A3%80%E6%9F%A5%20struct.json%20%E9%87%8C%E6%AF%8F%E4%B8%AA%20edgeLabel%20%E7%9A%84%20value_mapping%20%E6%98%AF%E5%90%A6%E5%92%8C%20schema.groovy%20%E5%AE%8C%E5%85%A8%E4%B8%80%E8%87%B4%E3%80%82%2A%2A%0A%0A%E5%A6%82%E8%BF%98%E6%9C%89%E9%97%AE%E9%A2%98%EF%BC%8C%E5%8F%AF%E4%BB%A5%E8%B4%B4%E5%87%BA%E4%B8%80%E5%B0%8F%E6%AE%B5%20edge_connected_to.csv%EF%BC%88%E5%90%AB%20source_label/target_label%EF%BC%89%E5%92%8C%20struct.json%20%E7%9A%84%E5%AE%8C%E6%95%B4%20edge%20%E9%85%8D%E7%BD%AE%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-15204416 ---- This is an automatically sent email for [email protected]. To unsubscribe, please send an email to: [email protected]
