【问题标题】:Does CosmosDB Graph Api support hasNot?CosmosDB Graph Api 是否支持 hasNot?
【发布时间】:2017-09-17 05:16:19
【问题描述】:

我正在测试 CosmosDB 的 Gremlin 支持,并正在考虑在查询步骤中使用 hasNot。根据documentation我可以找到我看到了

has - 用于过滤属性、顶点和边。支持 hasLabel、hasId、hasNot 和有变体。

使用 Gremlin 控制台中的默认 Azure 示例图,我可以运行

gremlin> :> g.V().has('firstName')

并得到我期望的合理结果,

gremlin> :> g.V().hasNot('firstName')

导致来自 Azure 的令人鼓舞的堆栈跟踪响应非常有信心(删除了 id 以防万一)。

Gremlin Query Compilation Error: Traversal Script: Failed to compile query:
(1,74): error CS1061: Type `Microsoft.Azure.Graphs.GraphTraversal' does not contain a definition for `hasNot' and no extension method `hasNot' of type `Microsoft.Azure.Graphs.GraphTraversal' could be fou$
d. Are you missing an assembly reference?
D:\local\Temporary ASP.NET Files\root\<removed>\<removed>\assembly\dl3\<removed>\<removed>\Microsoft.Azure.Graphs.dll (Location of the symbol related to previous error)
                ExceptionType : GraphCompileException
                Source : Microsoft.Azure.Graphs
                Context : <removed>
                RequestId : <removed>
                Scope : graphcmd-emitcode
                Status : ScriptEvaluationError
                HResult : 0x80131500
   at Microsoft.Azure.Graphs.Common.MonoTraversalScript.HandleCompileError(Tuple`2& evaluationContext)
   at Microsoft.Azure.Graphs.Common.MonoTraversalScript.Compile()
   at Microsoft.Azure.Graphs.GraphCommand.<ExecuteTraversalAsync>b__38_0()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Graphs.GraphCommand.<ExecuteTraversalAsync>d__38.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Graphs.GremlinServer.DefaultGraphRequestProcessor.<CreateGremlinResponseInternalAsync>d__13.MoveNext()

关键部分当然是第一行中似乎表明 hasNot 在用于编译服务器上的查询的 Azure .NET dll 中没有适当定义的部分。

类似的结果来自仪表板中的查询资源管理器。

这可以通过

解决(至少在某种程度上)
gremlin> :> g.V().not(has('firstName'))

【问题讨论】:

  • 我不知道除了您提供的解决方法之外的解决方法,但仅供参考,服务器端没有发生查询编译。 gremlin 在客户端被解析并翻译成文档查询。您可以使用 Fiddler 或其他代理检查出站网络调用,以确切了解正在发出的查询。
  • 我会考虑验证这一点,但在客户端执行此操作似乎不太可能,因为我在 TinkerPop 代码上的 JRE 中运行,而不是使用 C# dll。当然,通过使用 .NET 界面中的 Fiddler 来查看原始调用进行调试可能最终成为一种有用的调试技术,用于查看几乎可以肯定错误出现在 Azure 端而不是 Gremlin 查询端。
  • 顺便说一句,现在支持。

标签: gremlin azure-cosmosdb


【解决方案1】:

很遗憾,hasNot() 步骤目前未在 CosmosDB Graph 上公开,这似乎是我们的疏忽。

我已将此问题添加到我们的待办事项中,并且由于它似乎已经部分实施,它可能会在下一个服务版本(约 2 周)中可用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-02-28
    • 1970-01-01
    • 1970-01-01
    • 2011-12-24
    • 2014-10-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多