Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Update the Value of Vertex in Gremlin Server ( Titan 1.0)

I'm having a vertex with following details:

http://localhost:8182/?gremlin=g.V(4192)

{

"requestId": "6ce01f3b-f623-41f6-bb03-dd56014e0701",
"status": 

{

"message": "",
"code": ​200,
"attributes": { }

},
"result": 
{

"data": 

[

{

"id": ​4192,
"label": "person",
"type": "vertex",
"properties": 

{

"name": 

[

{
    "id": "170-38g-sl",
    "value": "marko2"
}

],
"age": 
[

                    {
                        "id": "1l8-38g-28lh",
                        "value": ​29
                    }
                ]
            }
        }
    ],
    "meta": { }
}

}

I want to update the Name of the vertex :

I tried following query :

g.V(4192).setProperty('name','William')

But it is not updating , it is giving error

{

 "message": "Error encountered evaluating script: g.V(4192).setProperty('name','William')"

}
like image 577
Sumit Chourasia Avatar asked May 18 '16 12:05

Sumit Chourasia


People also ask

How do you get rid of the vertex in Gremlins?

remove() will also do the trick. If you have the vertex already then simply v. remove() . Any of the 3 will serve.

How do you add nodes in Gremlin?

In Gremlin nodes are referred to as “Vertexes”. To add a node/vertex to the graph, you simply use the command addV() on your graph traversal source. For consistency, most people use “g” as their default graph traversal source.


1 Answers

There is no method called "setProperty()" on a Traversal. You would do:

g.V(4192).property('name','William')

Please see the full list of steps in the TinkerPop documentation.

You could also work with the Vertex directly and do:

v = g.V(4192).next()
v.property('name','william')
like image 187
stephen mallette Avatar answered Oct 15 '22 15:10

stephen mallette