【发布时间】: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 查询端。
-
顺便说一句,现在支持。