We are using the Gremlin JavaScript language variant and Amazon Neptune in our project and we have multiple use cases for the creation of vertices and edges in batch.
A simple example would be an array of 200 - 1000 users. I need to perform a batch query that checks whether the user exists or not. If the user exists then add the vertices with the properties else ignore that user. All these conditions need to be done in batch.
Note: Usage of Gremlin scripts needs to be avoided. So traversal is what I am looking for.
It is possible to seed a query with a list of maps containing the data to be inserted. You can further extend the pattern to use a
coalescestep to do conditional inserts. Using the air-routes data set here is a simple example that creates a newXYZairport and figures out the other airports already exist. Note that the mid-traversalVstep makes this a somewhat expensive query as for each map in the list all vertices have to be "searched".There are additional discussions of using this pattern to avoid long chains of
addVandaddEsteps in a query.https://tinkerpop.apache.org/docs/current/recipes/#long-traversals
When the query is run you can see that a new ID is created for the XYZ airport and the existing IDs are found for the others.