Rexster: Gremlin

Bulbs API for executing Gremlin scripts on Rexster.

Gremlin comes in several variations:

  • Gremlin-Groovy (the original)
  • Gremlin-Java
  • Gremlin-Scala

Gremlin-JavaScript is in the works, and Gremlin-Jython is on deck to be completed after Gremlin-JavaScript.

Rexster currently supports the original Gremlin-Groovy, and the Rexster JavaScript extension is in the works.


Use the standard Bulbs Gremlin interface to execute Gremlin-Groovy scrips on Rexster.


>>> from bulbs.rexster import Graph
>>> g = Graph()
>>> script = g.scripts.get('get_movie_recommendations')
>>> params = dict(user_id=3)
>>> vertices = g.gremlin.query(script, params)
>>> vertex =

Here, “get_movie_recommendations” is a Gremln-Groovy script in your local Groovy library.

Loading Custom Functions

You can add a custom Groovy file to the scripts index like this:

>>> from bulbs.rexster import Graph
>>> g = Graph()
>>> file_path = "/home/james/code/myGremlinScripts.groovy"
>>> g.scripts.update(file_path)

Bulbs will parse the Groovy file and store each function in a dict, with its function name as the key. If one of the newly-loaded functions has the same name as an existing function, it will override the existing function with your custom script.

Refreshing Scripts

If you make changes to the Groovy file while the object is loaded, you can refresh the loaded scripts like this:

>>> g.scripts.refresh()