使用Gremlin.Net获取请求数据

时间:2020-05-12 03:17:34

标签: gremlin amazon-neptune gremlinnet

我正在使用Gremlin.Net和Neptune,有时某些请求会失败,并且错误消息(InternalFailureException)中没有太多信息。
我想尝试通过curl将请求发送到服务器的“ / gremlin / explain” URL,以获取更多信息。
由于我是使用GraphTraversal类构建请求的(很长),因此我正在寻找一种方法来获取与发送的请求等效的gremlin命令。
有什么简单的方法可以得到它吗?
还有其他方法可以了解为什么海王星未能通过请求吗?

1 个答案:

答案 0 :(得分:2)

我假设您想获取查询的字符串表示形式,以便可以将其发布到/gremlin/explain API中。使用Java和Javascript,可以使用TinkerPop的here中描述的Translator函数来相当直接地做到这一点。当然,对于.NET和Python,这类事情don't exist yet

由于您的情况听起来像您只需要一种一次性的解决方案来进行“解释”分析,您就可以在.NET中获得字节码的GraphSON表示形式,因此请使用Gremlin Console's :bytecode command将其转换为{{ 1}}表示形式。

因此,首先将String对象作为GraphSON:

Bytecode

将“ graphSON”字符串复制/粘贴到Gremlin Console中:

var bytecode = g.V().Out("knows").Bytecode;
var writer = new GraphSON3Writer();
var graphSON = writer.WriteObject(bytecode)

请注意,我在那里使用TinkerGraph作为主机来重建遍历。