GitHub user dosubot[bot] edited a comment on the discussion: 关于电网拓扑数据导入
<!-- Answer --> 你的 struct.json 配置还不能保证所有连接关系都能导入,原因是 HugeGraph 的每个 edgeLabel 只能连接一种源点和目标点类型,且 struct.json 里每个 edgeLabel 的配置会尝试导入整个 edge_connected_to.csv,但只有源/目标顶点 label 和 schema.groovy 里 edgeLabel 的 sourceLabel/targetLabel 完全匹配时才会真正导入成功,否则会被静默跳过(不会报错,但关系缺失)[参考](https://github.com/apache/incubator-hugegraph-doc/blob/3e1c610281c91ea3a5c600b393088e9ffae34799/content/en/docs/quickstart/toolchain/hugegraph-loader.md#L139-L1090)。 你的配置只覆盖了部分边类型,像 LineSegment2LineSegment、LineSegment2LineSwitch、LineSwitch2LineSegment 等常见的电网关系没有在 struct.json 里补全,所以这些类型的连接不会被导入。即使 edge_connected_to.csv 里有这些数据,loader 也会因为 label 不匹配 schema 而跳过。 **建议做法:** 1. 明确所有需要的边类型组合,比如: - Substation2LineSegment - LineSegment2Substation - LineSegment2StationHouse - StationHouse2LineSegment - LineSegment2LineSegment - LineSegment2LineSwitch - LineSwitch2LineSegment - StationHouse2LineSwitch - LineSwitch2StationHouse 2. schema.groovy 里为每种类型的连接都定义 edgeLabel,sourceLabel/targetLabel 必须和顶点 label 一致。 3. struct.json 里 edges 部分为每个 edgeLabel 配置一段,source/target 字段和顶点主键一致,value_mapping 只需把 label 字段映射为 edgeLabel 名称(如 "CONNECTED_TO": "LineSegment2LineSegment")。 4. edge_connected_to.csv 建议增加 source_label/target_label 字段(或用脚本拆分),这样每个 edgeLabel 配置时可以用 selected/value_mapping 精确筛选出属于自己的那部分边,避免类型不匹配被跳过。 **举例:** ```json { "label": "LineSegment2LineSegment", "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" }, "selected": ["from", "to"], "value_mapping": { "label": { "CONNECTED_TO": "LineSegment2LineSegment" }, "source_label": { "LineSegment": "LineSegment" }, "target_label": { "LineSegment": "LineSegment" } } } ``` 每种类型的边都要写一段,path 可以都指向同一个 CSV 文件。 **核心要点**:每个 edgeLabel 只能导入一种类型的连接,必须保证 struct.json 里每个 edgeLabel 配置只处理属于自己的那部分边,否则会被跳过,导致连接关系不全。loader 的“成功”只代表数据格式没错,不代表所有逻辑关系都建立了[官方文档说明](https://github.com/apache/incubator-hugegraph-doc/blob/3e1c610281c91ea3a5c600b393088e9ffae34799/content/en/docs/quickstart/toolchain/hugegraph-loader.md#L139-L1090)。 如需具体 struct.json/schema.groovy 模板或数据预处理脚本,可以补充你的需求。 <!-- 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=f7a54495-c74c-4416-b88b-1c641624839f) [](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-15204176 ---- This is an automatically sent email for [email protected]. To unsubscribe, please send an email to: [email protected]
