我试图确定与gremlin shell相比,rexster处理用户定义的Gremlin查询的方式似乎存在差异的原因。
我在用:
我已加载以定向表示简单层次树的图形。每个节点都有一个标记为“父”的边,它指向其父。它是DAG。
我在Gremlin中定义了一个用户定义的步骤(通过其init-scripts加载到rexster中)如下:
Gremlin.defineStep('children',
[Vertex, Pipe],
{int depth -> _().out('parent').loop(1)
{it.loops < depth}
{it.object != null}
})
在rexster狗屋中使用命令行gremlin工具时,通过这些命令,我得到以下错误(向右滚动以查看整个错误消息):
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]
但是,如果我启动了gremlin.sh,连接到我的图形,定义了该步骤,然后执行它,那么它可以完美地工作:
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
(注意:名称正确,我希望看到的是正确的名称)。
为什么我的gremlin脚本可以在gremlin控制台上运行,而不是通过bulbs / rexster运行?
在此先感谢您,我们将为您提供任何帮助,见解或指向适当文档的指导。
使用codeveloper
文档中定义的步骤版本时,我对此没有任何问题:
$ 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}
似乎也可以在Dog House工作。我最好的猜测是Rexster找不到脚本。您确定您的<init-scripts>
设置路径正确吗?如果正确指定并加载了初始化脚本,则应该看到此日志条目:
[INFO] EngineHolder - ScriptEngine initializing with a custom script
在ScriptEngine
启动之前,您将不会看到它,直到您对它发出请求(即,如我上面的curl命令)之后才会看到它。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句