Tinkerpop: Set Label After Creating Vertex

六月ゝ 毕业季﹏ 提交于 2019-12-13 00:53:45

问题


Is there a way to set the T.label after the vertex has been created. I have tried the following:

Vertex v = graph.addVertex();
v.property(T.label.name(), "test");

But when I try the following traversal:

graph.traversal().V().hasLabel("test").next

I get

org.apache.tinkerpop.gremlin.process.traversal.util.FastNoSuchElementException

Is there something special about T.label that limits it to being set at the step of constructing the vertex ?


回答1:


No, labels cannot be changed. If you need this type of functionality, you should use a vertex property instead.

From the TinkerPop documentation: "NOTE: In TinkerPop3, vertices are allowed a single immutable string label (similar to an edge label). This functionality did not exist in TinkerPop2. Likewise, element id’s are immutable as they were in TinkerPop2."



来源:https://stackoverflow.com/questions/34004702/tinkerpop-set-label-after-creating-vertex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!