Skip to content

Instantly share code, notes, and snippets.

@espeed
Created December 6, 2011 23:46
Show Gist options
  • Save espeed/1440650 to your computer and use it in GitHub Desktop.
Save espeed/1440650 to your computer and use it in GitHub Desktop.
Gremlin: Create Automatic Indexed Vertex
import groovy.json.JsonSlurper
def slurper = new JsonSlurper()
data = slurper.parseText('{"age":34,"name":"James"}')
elementIndex = g.idx('people')
verticesIndex = g.idx('vertices')
g.setMaxBufferSize(0)
g.startTransaction()
vertex = g.addVertex(data)
AutomaticIndexHelper.addElement(elementIndex,vertex)
AutomaticIndexHelper.addElement(verticesIndex,vertex)
g.stopTransaction(TransactionalGraph.Conclusion.SUCCESS)
return vertex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment