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

Sumit Chourasia picture Sumit Chourasia · May 18, 2016 · Viewed 8.6k times · Source

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')"

}

Answer

stephen mallette picture stephen mallette · May 18, 2016

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')