我有一个名为 /tmp/scripts/a.gremlin 的脚本,其中包含一个函数 filterOver。
def filterOver(age) {
return g.V.filter{it.age > age}
}
我的 rexster 配置 conf/rexster-cassandra.xml 包含正确的扩展部分。
<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>
我已经通过运行启动了我的 rexster 服务器
bin/titan.sh start
现在当我执行
http://localhost:8182/graphs/graph/tp/gremlin?script=filterOver(30)&load=[a]
我得到了例外
{"success":false,"api":{"description":"为图评估一个 ad-hoc Gremlin 脚本。","parameters":{"rexster.showTypes":"显示元素的属性及其本机数据类型(默认为 false)","load":"在“脚本”之前执行的“存储过程”列表(如果未指定“脚本”,则此参数中的最后一个脚本将返回值” ,"returnTotal":"设置为 true 时,将迭代整个结果集并返回结果(默认为 false)","language":"要使用的 gremlin 语言风格(默认为 groovy)","params" :"要绑定到脚本引擎的参数映射","script":"要评估的 Gremlin 脚本","rexster.returnKeys":"要返回的元素属性键数组(默认是返回所有元素属性)","rexster.offset.start":"分页集的开始索引要返回的数据","rexster.offset.end":"要返回的分页数据集的结束索引"}},"message":"","error":"javax.script.ScriptException: groovy. lang.MissingMethodException:没有方法签名:com.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine.filterOver() 适用于参数类型:(java.lang.Integer) 值:[30]"}start":"要返回的分页数据集的开始索引","rexster.offset.end":"要返回的分页数据集的结束索引"}},"message":"","error “:”javax.script.ScriptException:groovy.lang.MissingMethodException:没有方法签名:com.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine.filterOver()适用于参数类型:(java.lang.Integer)值: [30]"}start":"要返回的分页数据集的开始索引","rexster.offset.end":"要返回的分页数据集的结束索引"}},"message":"","error “:”javax.script.ScriptException:groovy.lang.MissingMethodException:没有方法签名:com.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine.filterOver()适用于参数类型:(java.lang.Integer)值: [30]"}filterOver() 适用于参数类型:(java.lang.Integer) 值:[30]"}filterOver() 适用于参数类型:(java.lang.Integer) 值:[30]"}
我也试过
http://localhost:8182/graphs/graph/tp/gremlin?params={%22age%22:30}&script=filterOver(age)&load=[a]
甚至以下
http://localhost:8182/graphs/graph/tp/gremlin?age=30&script=filterOver(age)&load=[a]
那么将参数传递给函数的正确方法是什么?