问题描述
如何从Java GraphTraversal
对象输出Gremlin查询?默认输出(graphTraversal.toString()
)看起来像[HasStep([~label.eq(brand), name.eq(Nike), status.within([VALID])])]
,不容易阅读.
How to output Gremlin query from a Java GraphTraversal
object? The default output (graphTraversal.toString()
) looks like [HasStep([~label.eq(brand), name.eq(Nike), status.within([VALID])])]
which is not easy to read.
推荐答案
克里姆林宫提供了GroovyTranslator类来帮助解决这一问题.这是一个例子.
Gremlin provides the GroovyTranslator class to help with that. Here is an example.
// Simple traversal we can use for testing a few things
Traversal t =
g.V().has("airport","region","US-TX").
local(values("code","city").
fold());
// Generate the text form of the query from a Traversal
String query;
query = GroovyTranslator.of("g").
translate(t.asAdmin().getBytecode());
System.out.println("\nResults from GroovyTranslator on a traversal");
System.out.println(query);
这是从位于此处的一组示例中获取的: https ://github.com/krlawrence/graph/blob/master/sample-code/RemoteWriteText.java
This is taken from a set of examples located here: https://github.com/krlawrence/graph/blob/master/sample-code/RemoteWriteText.java
这篇关于Java GraphTraversal输出Gremlin查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!