dosubot[bot] commented on issue #2776:
URL:
https://github.com/apache/incubator-hugegraph/issues/2776#issuecomment-2908650532
<!-- Answer -->
关于你的问题:“顶点使用 primaryKeys,idStrategy 自动使用 PrimaryKey,创建边时,能否使用 primaryKeys
对应值当 source-label 和 target-label,且顶点数据是分开创建的?”
根据 HugeGraph 的官方文档和源码分析:
- 在 HugeGraph 中,顶点的 primaryKeys 主要用于唯一标识顶点(即顶点 ID),而不是作为边的 source-label 或
target-label。
- 创建边时,source-label 和 target-label 必须是顶点类型(VertexLabel)的名称,而不是 primaryKey
的值。例如:
```java
schema.edgeLabel("knows")
.sourceLabel("person")
.targetLabel("person")
.properties("date", "weight")
.ifNotExist()
.create();
```
这里的 `"person"` 是顶点类型的名称,而不是 primaryKey 的值。primaryKey
的值用于唯一定位某个具体的顶点实例,而不是用于定义边的
schema。[参考文档](https://github.com/apache/incubator-hugegraph-doc/blob/master/content/en/docs/quickstart/hugegraph-client.md)
- 在实际插入边数据时,source 和 target 需要指定顶点的 ID(如果顶点是用 primaryKeys 生成的 ID,可以用
primaryKeys 的值来查找顶点 ID),但在 schema 层面,source-label 和 target-label
只能是顶点类型名。[RESTful API
文档示例](https://github.com/apache/incubator-hugegraph-doc/blob/master/content/en/docs/clients/restful-api/edge.md)
- 源码中,边的定义和序列化也是基于顶点类型(VertexLabel),而不是 primaryKey
的值。[源码示例](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/serializer/TextSerializer.java)
**结论**:
你不能直接用 primaryKeys 的值作为 source-label 和 target-label。
- source-label 和 target-label 必须是顶点类型(VertexLabel)的名称。
- 在插入边数据时,可以用 primaryKeys 的值来查找顶点 ID,然后用这些 ID 作为边的 source 和 target。
如需进一步举例或有具体的数据插入需求,可以补充说明。
<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://go.dosu.dev/dosubot), mention
@dosu-bot.*
---
<sup>Help Dosu learn! Give it feedback: [Great
Response](https://app.dosu.dev/response-feedback/3cd7d9e5-ad11-4066-914e-06e562f3c05a?feedback_type=great_response)
| [Irrelevant
Answer](https://app.dosu.dev/response-feedback/3cd7d9e5-ad11-4066-914e-06e562f3c05a?feedback_type=irrelevant_answer)
| [Incorrect
Sources](https://app.dosu.dev/response-feedback/3cd7d9e5-ad11-4066-914e-06e562f3c05a?feedback_type=incorrect_sources)
| [Too
Verbose](https://app.dosu.dev/response-feedback/3cd7d9e5-ad11-4066-914e-06e562f3c05a?feedback_type=too_verbose)
|
[Hallucination](https://app.dosu.dev/response-feedback/3cd7d9e5-ad11-4066-914e-06e562f3c05a?feedback_type=hallucination)
| [Bug
Report](https://app.dosu.dev/response-feedback/3cd7d9e5-ad11-4066-914e-06e562f3c05a?feedback_type=bug_report)
|
[Other](https://app.dosu.dev/response-feedback/3cd7d9e5-ad11-4066-914e-06e562f3c05a?feedback_type=other)</sup>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]