【问题标题】:AWS Neptune Gremlin C# GraphTraversalSource not workingAWS Neptune Gremlin C# GraphTraversalSource 不工作
【发布时间】:2020-12-01 01:36:12
【问题描述】:

我已经看到了多个这样做的例子(各种语言),这表明这应该可行。也许我错过了一步?注释掉表明我尝试过的其他事情的行。

这是我如何让我的 gremlin 客户端以及一个可以直接使用的 graphTraversalSource。

var gremlinServer = new GremlinServer(endpoint, 8182, enableSsl: true);
GremlinClient = new GremlinClient(gremlinServer);

//var remoteConnection = new DriverRemoteConnection(GremlinClient, "g");
var remoteConnection = new DriverRemoteConnection(GremlinClient);
//g = AnonymousTraversalSource.Traversal().WithRemote(remoteConnection);
g = new Graph().Traversal().WithRemote(remoteConnection);

如果我以这样的字符串形式提交查询:

var gndrSetCnt = GremlinQueryCount(GremlinClient, "g.V().count().next();");
var gndrResult = gndrSetCnt.Result;

然后……

private async Task<long> GremlinQueryCount(GremlinClient gremlinClient, string query)
{
    return await gremlinClient.SubmitWithSingleResultAsync<long>(query);
}

虽然很笨拙,但效果很好。但是,如果我尝试直接使用“g”,如下所示:

var example = g.V().Count().Next();

然后我收到这样的错误:

Gremlin.Net.Driver.Exceptions.ResponseException: 'InvalidRequestArguments: {"detailedMessage":"A message with [bytecode] op code requires the [aliases] argument to be a Map containing one alias assignment named 'g'.","requestId":"ae024dd7-0fca-472b-acc6-7f717ca4bf2d","code":"InvalidParameterException"}'

我错过了一步吗?我在多个示例中看到了这一点,似乎没有做其他任何事情,但我承认,只有一个在 C# 中,这只是部分代码,更多的是教程。似乎没有注入别名,g 似乎默认可用?再次注意,我在提交的 groovy 脚本中使用了 g,这很有效。

根据建议,我们添加了日志记录,这是一个示例语句产生的结果:

"RequestMessage{, requestId=709ba190-0ce9-4272-aadb-4b28c21accf6, op='bytecode', processor='traversal', args={gremlin={$type=System.Collections.Generic.Dictionary2[[System.String, mscorlib],[System.Object, mscorlib]], mscorlib, @type=g:Bytecode, @value={$type=System.Collections.Generic.Dictionary 2[[System.String, mscorlib],[System.Collections.Generic.IEnumerable1[[System.Collections.Generic.IEnumerable1[[System.Object, mscorlib]], mscorlib]], mscorlib]], mscorlib, step={$type=System. Linq.Enumerable+WhereSelectListIterator2[[Gremlin.Net.Process.Traversal.Instruction, Gremlin.Net],[System.Collections.Generic.IEnumerable1[[System.Object, mscorlib]], mscorlib]], System.Core, $values=[[V], [hasLabel, article], [has, languageCode, fr-FR] , [count]]}}}, 别名={$type=System.Collections.Generic.Dictionary2[[System.String, mscorlib],[System.Object, mscorlib]], mscorlib, g=g}, $type=System.Collections.Generic.Dictionary2[[System.String, mscorlib],[System.Object, mscorlib]], mscorlib}}"

我不完全确定这是否有帮助。最初的错误消息暗示该语句不是以“g”开头,但鉴于我正在做的事情,我不明白为什么它不是 - 这是从具有“g”的drm构建一个gts对象" 作为遍历源。

【问题讨论】:

  • 您使用的是哪个版本的 Gremlin.Net?另外,您可以尝试一下Gremlin Server是否有同样的问题?例如,您可以从 Docker 开始:docker run --rm -p 8182:8182 -it tinkerpop/gremlin-server。从我所看到的情况来看,您展示的代码应该可以正常工作。

标签: c# gremlin amazon-neptune


【解决方案1】:

您建立连接的方法是正确的,尽管这种方法现在已被弃用。您现在应该使用:

g = Traversal().withRemote(remoteConnection);

但是,这不是导致您的问题的原因。 Neptune 正在等待包含别名“g”的请求。最好在您的集群上启用审核日志记录,以准确查看您的代码作为别名而不是“g”发送的内容。

【讨论】:

  • 感谢您的回复,我们已经添加了日志记录,并且回复已添加到原始问题中。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-06-03
  • 2019-06-04
  • 1970-01-01
  • 1970-01-01
  • 2019-08-10
  • 1970-01-01
相关资源
最近更新 更多