How can I delete a Vertex in Gremlin Server Titan 1.0
Asked Answered
B

2

7

I'm using Titan 1.0 Version and Gremlin Server with REST Api for creating and updating Vertex details. How can I delete the vertex using vertexId?

Buyers answered 19/5, 2016 at 6:57 Comment(0)
S
18

you can use drop property to delete a vertex like :

g.V(vertexId).drop()

you will find more details about drop property on following link :

TinkerPop3 Documentation

Springe answered 19/5, 2016 at 6:59 Comment(3)
g.V(vertexId).next().remove() will also do the trick. If you have the vertex already then simply v.remove(). Any of the 3 will serve.Stereotaxis
Please note that g.V(vertexId).drop() without iterating the result will only work in Gremlin console that iterates results automatically. In a Java program, to actually trigger the removal, iteration needs to be requested like this: g.V(vertexId).drop().iterate()Orizaba
Also, if the Vertex instance you have is a ReferenceVertex (which seems to be the case when you are working via a remote connection), v.remove() will not work at all as removal is not supported for ReferenceVertex.Orizaba
C
4

You can use :

 g.V().hasId(vertexId).drop()

In the hasId method pass the id of the vertex you want to delete

Chiao answered 6/6, 2017 at 8:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.