GitHub user wangzhewwzz added a comment to the discussion: 关于电网拓扑数据导入
{
"vertices": [
{
"label": "Substation",
"input": {
"type": "file",
"path":
"/loader/power_data/vertex_substation-1.csv",
"format": "CSV",
"header": ["id", "name", "objectType",
"objectHandle", "deviceType", "internalEndpointNo", "terminalNo", "usage",
"powerFlowDirection", "belongSubstation", "belongFeeder"],
"charset": "UTF-8"
},
"null_values": ["NULL", "null", ""]
},
{
"label": "LineSegment",
"input": {
"type": "file",
"path":
"/loader/power_data/vertex_linesegment-1.csv",
"format": "CSV",
"header": ["id", "name", "objectType",
"objectHandle", "deviceType", "internalEndpointNo", "terminalNo", "usage",
"powerFlowDirection", "belongSubstation", "belongFeeder"],
"charset": "UTF-8"
},
"null_values": ["NULL", "null", ""]
},
{
"label": "LineSwitch",
"input": {
"type": "file",
"path":
"/loader/power_data/vertex_lineswitch-1.csv",
"format": "CSV",
"header": ["id", "name", "objectType",
"objectHandle", "deviceType", "internalEndpointNo", "terminalNo", "usage",
"powerFlowDirection", "belongSubstation", "belongFeeder"],
"charset": "UTF-8"
},
"null_values": ["NULL", "null", ""]
},
{
"label": "StationHouse",
"input": {
"type": "file",
"path":
"/loader/power_data/vertex_stationhouse-1.csv",
"format": "CSV",
"header": ["id", "name", "objectType",
"objectHandle", "deviceType", "internalEndpointNo", "terminalNo", "usage",
"powerFlowDirection", "belongSubstation", "belongFeeder"],
"charset": "UTF-8"
},
"null_values": ["NULL", "null", ""]
}
],
"edges": [
{
"label": "Substation2LineSegment",
"source": ["from"],
"target": ["to"],
"input": {
"type": "file",
"path": "/loader/power_data/edge_connected_to.csv",
"format": "CSV",
"header": ["id", "from", "to", "label"]
},
"field_mapping": {
"from": "id",
"to": "id"
},
"selected": ["from", "to"],
"value_mapping": {
"label": {
"CONNECTED_TO": "Substation2LineSegment"
}
}
},
{
"label": "LineSegment2Substation",
"source": ["to"],
"target": ["from"],
"input": {
"type": "file",
"path": "/loader/power_data/edge_connected_to.csv",
"format": "CSV",
"header": ["id", "from", "to", "label"]
},
"field_mapping": {
"from": "id",
"to": "id"
},
"selected": ["from", "to"],
"value_mapping": {
"label": {
"CONNECTED_TO": "LineSegment2Substation"
}
}
},
{
"label": "LineSegment2StationHouse",
"source": ["from"],
"target": ["to"],
"input": {
"type": "file",
"path": "/loader/power_data/edge_connected_to.csv",
"format": "CSV",
"header": ["id", "from", "to", "label"]
},
"field_mapping": {
"from": "id",
"to": "id"
},
"selected": ["from", "to"],
"value_mapping": {
"label": {
"CONNECTED_TO": "LineSegment2StationHouse"
}
}
},
{
"label": "StationHouse2LineSegment",
"source": ["to"],
"target": ["from"],
"input": {
"type": "file",
"path": "/loader/power_data/edge_connected_to.csv",
"format": "CSV",
"header": ["id", "from", "to", "label"]
},
"field_mapping": {
"from": "id",
"to": "id"
},
"selected": ["from", "to"],
"value_mapping": {
"label": {
"CONNECTED_TO": "StationHouse2LineSegment"
}
}
},
{
"label": "StationHouse2LineSwitch",
"source": ["from"],
"target": ["to"],
"input": {
"type": "file",
"path": "/loader/power_data/edge_connected_to.csv",
"format": "CSV",
"header": ["id", "from", "to", "label"]
},
"field_mapping": {
"from": "id",
"to": "id"
},
"selected": ["from", "to"],
"value_mapping": {
"label": {
"CONNECTED_TO": "StationHouse2LineSwitch"
}
}
},
{
"label": "LineSwitch2StationHouse",
"source": ["to"],
"target": ["from"],
"input": {
"type": "file",
"path": "/loader/power_data/edge_connected_to.csv",
"format": "CSV",
"header": ["id", "from", "to", "label"]
},
"field_mapping": {
"from": "id",
"to": "id"
},
"selected": ["from", "to"],
"value_mapping": {
"label": {
"CONNECTED_TO": "LineSwitch2StationHouse"
}
}
}
]
} 麻烦您看这样写关系包含全了吗?导入的时候这样写的 但是库里关系不全
原始邮件
发件人:dosubot[bot] ***@***.***>
发件时间:2025年12月9日 11:04
收件人:apache/incubator-hugegraph ***@***.***>
抄送:wangzhewwzz ***@***.***>, Mention ***@***.***>
主题:Re: [apache/incubator-hugegraph] 关于电网拓扑数据导入 (Discussion #2917)
你导入成功但连接关系不全,最常见的原因是 struct.json 里的 edges
配置没有把所有类型的边(比如变电站-线路、线路-站房、线路-开关等)都正确映射到 schema.groovy 里定义的 edgeLabel。HugeGraph
的边标签(edgeLabel)只能连接一种源点和目标点类型,且必须和顶点的 label 完全匹配,否则边会被跳过但不会报错,loader
只统计“插入成功”但实际没有建立你想要的关系 源码机制说明。
你现在 struct.json 只定义了 CONNECTED_TO 这一个 edgeLabel,且 source/target 都是 id,实际只会导入
Substation-Substation 这种关系,其他类型(比如
Substation-LineSegment、LineSegment-StationHouse、LineSegment-LineSwitch
等)都不会导入成功。
解决办法:
schema.groovy 里每种类型关系都要有一个 edgeLabel,比如
Substation2LineSegment、LineSegment2StationHouse、LineSegment2LineSegment、LineSegment2LineSwitch、LineSwitch2LineSegment
等。
struct.json 里 edges 部分要为每个 edgeLabel 配置一段,source/target 字段要和顶点主键字段一致(比如
["from"], ["to"]),并用 value_mapping 或 selected 过滤出当前 edgeLabel 需要的边类型。
edge_connected_to.csv 只要有 from、to、label 字段即可,所有边都放一起没问题,struct.json 里用
value_mapping 匹配不同 edgeLabel。
举例:
{ "label": "Substation2LineSegment", "source": ["from"],
"target": ["to"], "input": { "type": "file", "path":
"/loader/power_data/edge_connected_to.csv", "format": "CSV", "header": ["id",
"from", "to", "label"] }, "field_mapping": { "from": "id", "to": "id" },
"value_mapping": { "label": { "CONNECTED_TO": "Substation2LineSegment" }
} }, { "label": "LineSegment2StationHouse", "source": ["from"],
"target": ["to"], "input": { ... }, "field_mapping": { ...
}, "value_mapping": { "label": { "CONNECTED_TO":
"LineSegment2StationHouse" } } }
每种类型的边都要写一段,path 都可以指向同一个 edge_connected_to.csv。
注意:
顶点的 label 必须和 schema 里的 vertexLabel 一致,比如 LineSegment、StationHouse、LineSwitch 等。
edgeLabel 的 sourceLabel/targetLabel 必须和顶点 label 一一对应。
如果边是双向的,数据里要有正反两条记录(A→B 和 B→A),edgeLabel 只需定义一次。
参考案例和详细配置说明:
官方文档
社区类似问题与解决方法
如果你愿意,可以把 struct_1.json 和 schema_1.groovy 贴出来,我可以帮你逐条检查。
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose |
Hallucination | Report 🐛 | Other
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.
GitHub link:
https://github.com/apache/incubator-hugegraph/discussions/2917#discussioncomment-15204139
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]