Skip to content

Instantly share code, notes, and snippets.

@espeed
Created December 10, 2011 02:11
Show Gist options
  • Save espeed/1454298 to your computer and use it in GitHub Desktop.
Save espeed/1454298 to your computer and use it in GitHub Desktop.
Scoped Groovy
def create_indexed_vertex(data,index_name,keys) {
manager = g.getRawGraph().index()
index = manager.forNodes(index_name)
g.setMaxBufferSize(0)
g.startTransaction()
vertex = g.getRawGraph().createNode()
for (entry in data.entrySet()) {
if (entry.value == null) continue;
vertex.setProperty(entry.key,entry.value)
if (keys == null || keys.contains(entry.key))
index.add(vertex,entry.key,entry.value)
}
g.stopTransaction(TransactionalGraph.Conclusion.SUCCESS)
return vertex
}
return create_indexed_vertex(data,index_name,keys)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment