Search code examples
graphgremlinjanusgraph

Creating edge using vertex ids


I am trying to bulk load data into janusgraph. I am trying to follow bulk load recommendations I am strugling with point (d) which is "Add all the edges using the map to look-up JanusGraph’s vertex id and retrieving the vertices using that id"

My current code(scala) looks like

val key = Key[String]("Key")
val sLabel : StepLabel[Vertex] = StepLabel("target")
case (src, edgeType, dest) =>
graph.V().has(key, dest).as(sLabel).traversal.V().has(key, src).addE(edgeType).to(sLabel).traversal
.property("propertyKey", "propertyValue")

I have vertexId of source and dest vertex but I am unable to figureout how to change this code to create edge using vertexIds.

I am quite new to gremlin, any help would be appreciated.


Solution

  • case (idSrc, edgeType, idDest) =>
    g.V(idSrc).as("a").V(idDest).addE(edgeType).from("a")