Tommu10ve commented on issue #2777:
URL: 
https://github.com/apache/incubator-hugegraph/issues/2777#issuecomment-2908990150

   > 可以,HugeGraph 支持通过 PrimaryKey(主键属性)直接绑定主键值来实现边的创建。具体来说:
   > 
   > * 当你在 schema 中为顶点设置了 primaryKeys(如 id),顶点的 ID 策略会自动变为 PRIMARY_KEY。
   > * 这时,顶点的唯一标识就是主键属性的值,无需显式指定顶点 ID。
   > * 在创建边时,可以直接用主键值(如 "pk_001"、"pk_002")作为源/目标顶点的标识,HugeGraph 会自动根据 
VertexLabel 和 PrimaryKeyValues 生成顶点 ID 并完成边的绑定。
   > 
   > 你的 Groovy 示例是正确的用法:
   > 
   > schema.vertexLabel("person").primaryKeys("id").create();
   > graph.addVertex(T.label, "person", "id", "pk_001", "name", "张三");
   > graph.addVertex(T.label, "person", "id", "pk_002", "name", "李四");
   > graph.addEdge(T.label, "knows", 
   >              T.source, "pk_001",  // 源顶点主键值
   >              T.target, "pk_002"); // 目标顶点主键值
   > 官方文档说明:
   > 
   > * PRIMARY_KEY 策略下,顶点 ID 由 VertexLabel + PrimaryKeyValues 生成,类型为 
String,且数据会基于主键去重,无需手动指定 ID 
[参考](https://github.com/apache/incubator-hugegraph-doc/blob/master/content/cn/docs/guides/desgin-concept.md)。
   > * 在边的映射中,如果顶点采用 PRIMARY_KEY 策略,需指定一列或多列用于拼接生成顶点的 ID,即可直接用主键值绑定 
[参考](https://github.com/apache/incubator-hugegraph-doc/blob/master/content/cn/docs/quickstart/hugegraph-loader.md)。
   > 
   > 总结:你可以直接用主键值来创建边,无需显式指定顶点 ID,HugeGraph 会自动处理。
   > 
   > _To continue talking to [Dosu](https://go.dosu.dev/dosubot), mention 
[@dosu-bot](https://github.com/dosu-bot)._
   > 
   > Help Dosu learn! Give it feedback: [Great 
Response](https://app.dosu.dev/response-feedback/571642ab-7a02-4608-a3df-be5718fa6d12?feedback_type=great_response)
 | [Irrelevant 
Answer](https://app.dosu.dev/response-feedback/571642ab-7a02-4608-a3df-be5718fa6d12?feedback_type=irrelevant_answer)
 | [Incorrect 
Sources](https://app.dosu.dev/response-feedback/571642ab-7a02-4608-a3df-be5718fa6d12?feedback_type=incorrect_sources)
 | [Too 
Verbose](https://app.dosu.dev/response-feedback/571642ab-7a02-4608-a3df-be5718fa6d12?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/571642ab-7a02-4608-a3df-be5718fa6d12?feedback_type=hallucination)
 | [Bug 
Report](https://app.dosu.dev/response-feedback/571642ab-7a02-4608-a3df-be5718fa6d12?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/571642ab-7a02-4608-a3df-be5718fa6d12?feedback_type=other)
   
   有没有完整的 案例 


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

Reply via email to