0
votes

I have a script named /tmp/scripts/a.gremlin which contains a single function filterOver.

def filterOver(age) {
  return g.V.filter{it.age > age}
}

My rexster configuration conf/rexster-cassandra.xml contains the correct extensions section.

<extensions>
  <allows>
    <allow>tp:gremlin</allow>
  </allows>
  <extension>
    <namespace>tp</namespace>
      <name>gremlin</name>
      <configuration>
        <scripts>/tmp/scripts</scripts>
        <allow-client-script>true</allow-client-script>
        <cache-scripts>true</cache-scripts>
      </configuration>
    </extension>
</extensions>

I have started my rexster server by running

bin/titan.sh start

Now when I execute

http://localhost:8182/graphs/graph/tp/gremlin?script=filterOver(30)&load=[a]

I get the exception

{"success":false,"api":{"description":"evaluate an ad-hoc Gremlin script for a graph.","parameters":{"rexster.showTypes":"displays the properties of the elements with their native data type (default is false)","load":"a list of 'stored procedures' to execute prior to the 'script' (if 'script' is not specified then the last script in this argument will return the values","returnTotal":"when set to true, the full result set will be iterated and the results returned (default is false)","language":"the gremlin language flavor to use (default is groovy)","params":"a map of parameters to bind to the script engine","script":"the Gremlin script to be evaluated","rexster.returnKeys":"an array of element property keys to return (default is to return all element properties)","rexster.offset.start":"start index for a paged set of data to be returned","rexster.offset.end":"end index for a paged set of data to be returned"}},"message":"","error":"javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: com.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine.filterOver() is applicable for argument types: (java.lang.Integer) values: [30]"}

I have also tried

http://localhost:8182/graphs/graph/tp/gremlin?params={%22age%22:30}&script=filterOver(age)&load=[a]

and even the following

http://localhost:8182/graphs/graph/tp/gremlin?age=30&script=filterOver(age)&load=[a]

So what is the correct way of passing parameters to functions?

1

1 Answers

1
votes

I tried your specific configuration and it works for me. Your rexster.xml configuration seems to look right, as does your a.gremlin. There doesn't seem to be a problem with keeping that script in /tmp/scripts. This specific call with cURL worked for me:

curl "http://localhost:8182/graphs/tinkergraph/tp/gremlin?script=filterOver(30)&load=\[a\]"

If trying with cURL doesn't work for you I would suggest simplifying your rig, and trying with just a download of Rexster itself. Make sure that works and if it does then simulate again with Titan Server.