Question

I want to set multiple properties to the same edge.

tialVertex.addEdge("temp",headVertex).setProperty("key1", "value1");

The above command sets only one key-value pair. If I use it again, lets say for "key2","value2", it will create another edge with the same label(temp) between same vertex instead of appending key-value pair to the edge.

To put together I want one edge having to or more properties("key1":"value1" , "key1":"value1"....)

Please help me.

Was it helpful?

Solution

Unless you are using Gremlin, Titan (and the Blueprints API) does not allow for a multi-setter for properties. Note that this is not true in Gremlin Groovy:

tialVertex.addEdge("temp",headVertex, [key1:"value1",key2:"value2"])

there are helper methods in Blueprints that you might find useful:

ElementHelper.setProperties(tialVertex.addEdge("temp",headVertex), "key1","value1","key2","value2")

Note that this approach offers no additional performance enhancements on insert. And of course, you could always just assign the Edge to a variable and setProperty from there:

Edge e = tialVertex.addEdge("temp",headVertex);
e.setProperty("key1","value1");
e.setProperty("key2","value2");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top