GitHub user dosubot[bot] edited a comment on the discussion: 关于电网拓扑数据导入
<!-- Answer --> 你的理解**基本正确**,但有两个关键点需要注意,否则会导致关系不全: 1. **value_mapping 的作用** value_mapping 只是把 CSV 某一列的值(如 label/source_label/target_label)映射为你 schema.groovy 里定义的 edgeLabel 或属性值。它本身**不会过滤行**,只是把值替换后再尝试导入。如果 CSV 里没有 source_label/target_label 字段,或者内容不对,edgeLabel 还是会尝试导入所有行,但只有源/目标顶点 label 和 schema 里的 sourceLabel/targetLabel 完全匹配时才会真正导入成功,否则会被静默跳过(不会报错,但关系缺失)[参考](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/schema/builder/EdgeLabelBuilder.java)。 2. **CSV 必须有 source_label/target_label 字段且内容正确** 你写 `"source_label": { "LineSegment": "LineSegment" }, "target_label": { "LineSegment": "LineSegment" }`,前提是 edge_connected_to.csv 里有 source_label/target_label 两列,且 from/to 对应的顶点类型已经写进去了。例如: ``` id,from,to,label,source_label,target_label edge_1,XLD-3445,HWX-3087,CONNECTED_TO,LineSegment,StationHouse edge_2,HWX-3087,XLD-3258,CONNECTED_TO,StationHouse,LineSegment ... ``` 这样 struct.json 里每个 edgeLabel 的 value_mapping 才能精确筛选属于自己的那部分边,否则会被跳过。 3. **每种类型的边都要写一段 edgeLabel 配置** 比如 LineSegment2LineSegment、LineSegment2StationHouse、StationHouse2LineSegment、LineSegment2LineSwitch、LineSwitch2LineSegment、Substation2LineSegment、LineSegment2Substation 等,每种都要写一段,且 value_mapping 里的 label/source_label/target_label 都要和 schema.groovy 里的 edgeLabel、sourceLabel、targetLabel 完全一致。 **典型配置示例:** ```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 完全一致。 - 导入后用 REST API 查询各类边的数量和类型,验证关系是否齐全。 如还有问题,可以贴出一小段 edge_connected_to.csv 和 struct.json 的完整 edge 配置,我可以帮你逐条检查。 详细机制见[源码说明](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/schema/builder/EdgeLabelBuilder.java)。 <!-- 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=59144b43-3212-4402-956e-0ec575f55b6f) [](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-15204334 ---- This is an automatically sent email for [email protected]. To unsubscribe, please send an email to: [email protected]
