GitHub user wangzhewwzz added a comment to the discussion: 关于电网拓扑数据导入

您好 我马上要汇报了 我发您的附件 您能看到吗  我value_mapping 是这样么写的
"value_mapping": {  "label": { "CONNECTED_TO": "LineSegment2LineSegment" 
},  "source_label": { "LineSegment": "LineSegment" }, 
 "target_label": { "LineSegment": "LineSegment" } } 附件可以直接帮我改好吗 改好让后用附件发我 
问导入后 一会汇报
         原始邮件
         
       
发件人:dosubot[bot] ***@***.***>
发件时间:2025年12月9日 15:02
收件人:apache/incubator-hugegraph ***@***.***>
抄送:wangzhewwzz ***@***.***>, Mention ***@***.***>
主题:Re: [apache/incubator-hugegraph] 关于电网拓扑数据导入 (Discussion #2917)




你的配置还有两个关键点需要修正,否则边会全部插入失败:

edge_connected_to.csv 的 id 字段不要导入为边属性
 HugeGraph 边的属性必须在 schema.groovy 的 edgeLabel 里用 .properties() 明确声明,否则 loader 会报 
“Invalid property 'id' for edge label” 错误。如果你不需要把 id 
作为边的属性存储(绝大多数场景都不需要),struct.json 的 field_mapping 只写 from/to,不要写 id。比如:
"field_mapping": { "from": "id", "to": "id" }

edgeLabel 的 .properties() 只写 "source_label", "target_label"(如果你需要存储 
source_label/target_label),不要加 "id"。

value_mapping 必须是平铺结构,不能嵌套
 正确写法是:
"value_mapping": {   "label": { "CONNECTED_TO": "LineSegment2LineSegment" 
},   "source_label": { "LineSegment": "LineSegment" },  
 "target_label": { "LineSegment": "LineSegment" } }

不要写成嵌套在 label 下面的结构。


标准写法举例:

schema.groovy(以 LineSegment2LineSegment 为例):
schema.edgeLabel("LineSegment2LineSegment")    
 .sourceLabel("LineSegment")     .targetLabel("LineSegment")  
   .properties("source_label", "target_label")    
 .ifNotExist().create();

struct.json(以 LineSegment2LineSegment 为例):
{   "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" },   "value_mapping": {     "label": { 
"CONNECTED_TO": "LineSegment2LineSegment" },     "source_label": { 
"LineSegment": "LineSegment" },     "target_label": { "LineSegment": 
"LineSegment" }   } }


检查清单:

edgeLabel 的 .properties() 只包含实际需要的属性(如 "source_label", "target_label"),不要加 "id"。

struct.json 的 field_mapping 只写 from/to,不要写 id。

value_mapping 必须是平铺结构。

edge_connected_to.csv 的 source_label/target_label 必须和顶点 label 完全一致(区分大小写)。

这样配置后,边就能正常导入且无报错。如果还有具体报错,可以贴出 struct.json/schema.groovy/CSV 的片段,我可以帮你逐条检查。
 详细机制见官方文档。

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-15205494

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]

Reply via email to