从顶点移除标签

Removing a label from Vertex

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() 的方法来移除标签而不移除顶点。

您可以在位于 [1]

的 Apache TinkerPop 文档中找到此文本

"This is because TinkerPop does not allow the vertex label to be changed after the vertex has been created."

根据 TinkerPop 参考文档和实现,不允许在创建顶点标签后更改它。据我所知,即使不是所有启用 TinkerPop 的图形数据库,大多数人也都尊重这一点。

您找到的示例是直接连接(不是通过 Gremlin 服务器连接方式)时对 Neo4J 的自定义支持的一部分,其中可以直接操作顶点对象。

如果您需要可编辑标签的概念,我建议您改用 属性。就按 属性 与按标签查找而言,最终结果将大致相同,而且更便携。

[1] http://tinkerpop.apache.org/docs/current/reference/#_graphml_reader_writer