3

I have trouble finding a way of adding a new property to an existing vertex using gremlin. ex property to add: the property "name" with value "anna".

First I try to find the vertex which I want to add the property to. I do this by: g.v(id), where id is the id of the vertex I'm looking for.

Then I've tried adding the property to the vertex by doing: g.v(id).property("name","anna"), but this does not work and gives me an error saying:

"message":"","error":"javax.script.ScriptException: groovy.lang.MissingMethodException: No
signature of method: groovy.lang.MissingMethodException.property() is applicable for argument types: (java.lang.String, java.lang.String) values:

It says here http://www.tinkerpop.com/docs/3.0.0.M1/#giraph-gremlin under "Mutation the graph" that this is the way to add a new property to an existing vertex.

Any suggestions?

agiledevpro
  • 133
  • 1
  • 5
  • 17

1 Answers1

1

You can achieve that with sideEffect:

g = TinkerGraphFactory.createTinkerGraph()
g.V[0].map
==>{name=lop, lang=java}
g.V[0].sideEffect{it.foo = 'bar'}
g.V[0].map
==>{name=lop, foo=bar, lang=java}

I guess in a script you would need to add an .iterate() at the end of the modification statement.

Faber
  • 1,504
  • 2
  • 13
  • 21