簡體   English   中英

Amazon Neptune:如何使用 tinkerpop/gremlinpython package 在 Python 中創建自定義頂點 ID?

[英]Amazon Neptune: How to create custom vertex id in Python using tinkerpop/gremlinpython package?

如此處所述https://docs.aws.amazon.com/neptune/latest/userguide/access-graph-gremlin-differences.html自定義頂點 id 只能使用未引用的id屬性設置,即g.addV('label1').property(id, 'customid') 如何使用 gremlinpython package 實現這一目標? 我在 gremlin_python.process.graph_traversal 中看到一個id gremlin_python.process.graph_traversal ,但是在嘗試使用它時我得到一個UnsupportedOperationException (如預期的那樣)。

您應該只需要導入T這是包含idlabel成員的 class :

from gremlin_python.process.traversal import T

然后將其用作:

g.addV('label1').property(T.id, 'customid').iterate()

您當然可以選擇從T導入id以使語法與問題中的示例 Gremlin 同義,這樣您就可以省略T - 有些人更喜歡這種風格。

可能值得查看 Gremlin 使用的其他常見導入的參考文檔。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM