Amazon Neptune 支持一个顶点的多个标签。虽然我可以向顶点添加新标签,但我找不到删除它的方法。
我发现
vertex.addLabel('human')
vertex.removeLabel('human')
http://tinkerpop.apache.org/docs/current/reference/#_multi_label
AWS Neptune 不支持。
还尝试 drop()
标签,例如属性不起作用。
海王星 documentation说:
gremlin> g.addV('label1').property(id, 'customid')
gremlin> g.addV('label2').property(id, 'customid')
gremlin> g.V('customid').label()
==>label1::label2
但是这样你就只能添加标签,而不能删除标签。
我正在寻找像 removeLabel()
这样的方法来删除标签而不删除顶点。
最佳答案
您可以在 Apache TinkerPop 文档 [1] 中找到此文本
“这是因为 TinkerPop 不允许在创建顶点后更改顶点标签。”
根据 TinkerPop 引用文档和实现,不允许在创建顶点标签后更改顶点标签。据我所知,大多数(如果不是全部)TinkerPop 启用的图形数据库都尊重这一点。
您发现的示例是直接连接时 Neo4J 自定义支持的一部分(不是通过 Gremlin 服务器样式的连接),可以直接操作顶点对象。
如果您需要可编辑标签的概念,我建议您使用属性。按属性查找与按标签查找的最终结果大致相同,而且更加便携。
[1] http://tinkerpop.apache.org/docs/current/reference/#_graphml_reader_writer
关于gremlin - 从 Vertex 中删除标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54019536/