User defined gremlin step works in gremlin, but not in rexster

243 views Asked by At

I am trying to determine the cause of what seems to be a discrepancy in the way rexster handles user defined Gremlin queries, compared with the gremlin shell.

I am using:

  • rexster-server-2.6.0;
  • gremlin-groovy-2.5.0;
  • orientdb-community-1.7.9;

I have loaded in to orient a graph representing a simple hierarchy tree. Each node has an edge labeled 'parent' that points to its parent. It is a DAG.

I have defined a user-defined step in Gremlin (loaded into rexster via its init-scripts) as follows:

   Gremlin.defineStep('children', 
      [Vertex, Pipe], 
      {int depth ->  _().out('parent').loop(1) 
        {it.loops < depth} 
        {it.object != null} 
    })

When using the command-line gremlin tool in the rexster doghouse, with these commands, I get the following error (scroll to right to see entire error message):

gremlin> g.V('type', 'LSNetwork')
==>v[#9:6312]
gremlin> g.V('type', 'LSNetwork').out('parent').out('parent').name
==>Leaf 0
==>Leaf 1
==>Leaf 2
==>Leaf 3   
gremlin> g.V('type', 'LSNetwork').children(2)
==>javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: com.tinkerpop.gremlin.groovy.GremlinGroovyPipeline.children() is applicable for argument types: (java.lang.Integer) values: [2]

However, if I fire up the gremlin.sh, connect to my graph, define the step, and execute it, it works perfectly:

gremlin> Gremlin.defineStep('children', [Vertex, Pipe], {int depth -> _().out('parent').loop(1){it.loops < depth}{it.object != null}})
==>null
gremlin> sg=new OrientGraph('remote:localhost/scratch')                                                                               
==>orientgraph[remote:localhost/scratch]
gremlin> sg.V('type','LSNetwork').children(3).name
==>Spine 0
==>Spine 1
==>Leaf 0
==>Leaf 1
==>Leaf 2
==>Leaf 3

(Note: the names are correct and what I expect to see).

Why is my gremlin script working from the gremlin console, but not through bulbs/rexster?

Thanks in advance and any help, insights, or pointers to appropriate documentation are appreciated.

1

There are 1 answers

1
stephen mallette On BEST ANSWER

I'm not having a problem with this when using a version of the codeveloper step defined in the documentation:

$ curl "http://localhost:8182/graphs/tinkergraph/tp/gremlin?script=g.v(1).codeveloper.name"
{"success":true,"results":["josh","peter"],"version":"2.5.0","queryTime":39.294181}

seems to work in Dog House as well. My best guess is that Rexster is not finding the script. Are you sure you have your path right for the <init-scripts> setting? You should see this log entry if an init script was properly specified and loaded:

[INFO] EngineHolder - ScriptEngine initializing with a custom script

You won't see it until the ScriptEngine is started which won't happen until you make a request against it (i.e. like my curl command above).