GitHub user dosubot[bot] edited a comment on the discussion: 关于电网拓扑数据导入
<!-- Answer --> 你的配置问题已经很明确:**边数据的 id 字段被错误地当作边属性导入了,但 schema.groovy 的边标签没有声明 id 属性**,所以 HugeGraphLoader 报 “Invalid property 'id' for edge label” 错误[参考](https://github.com/apache/incubator-hugegraph-doc/blob/master/content/en/docs/guides/faq.md)。 **怎么修正:** 1. **struct.json 的 field_mapping 必须只写 from/to,不要写 id** ```json "field_mapping": { "from": "from", "to": "to" } ``` 这样 loader 只会用 from/to 字段去查找顶点,不会把 id 字段当作边属性导入。 2. **schema.groovy 的 edgeLabel .properties() 只写实际需要的属性** 例如: ```groovy schema.edgeLabel("LineSegment2LineSegment") .sourceLabel("LineSegment") .targetLabel("LineSegment") .properties("source_label", "target_label") .ifNotExist().create(); ``` 不要加 "id"。 3. **edge_connected_to.csv 的 id 列可以保留,但 loader 不会导入它为边属性**,只要 field_mapping 不写 id 就不会报错。 4. **value_mapping 必须是平铺结构**,你现在的写法没问题。 **你现在的 field_mapping 写成了:** ```json "field_mapping": { "from": "id", "to": "id" } ``` 这会把 CSV 的 id 列当作边属性导入,导致报错。**正确写法应该是:** ```json "field_mapping": { "from": "from", "to": "to" } ``` 这样 loader 只会用 from/to 字段去查找顶点,不会把 id 字段当作边属性导入。 **总结:** - struct.json 的 edges 里 field_mapping 只写 from/to,不要写 id。 - schema.groovy 的 edgeLabel .properties() 只写 "source_label", "target_label",不要加 "id"。 - edge_connected_to.csv 的 id 列可以保留,但 loader 不会导入它为边属性。 - value_mapping 是平铺结构即可。 这样配置后,边就能正常导入且无报错,所有关系都能导入。[官方FAQ说明](https://github.com/apache/incubator-hugegraph-doc/blob/master/content/en/docs/guides/faq.md) [源码机制说明](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/schema/EdgeLabel.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=ae4e48bc-87ad-4d80-8844-147af05e25ad) [](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-15205949 ---- This is an automatically sent email for [email protected]. To unsubscribe, please send an email to: [email protected]
