首页 > 解决方案 > 在 azure cosmosdb graph.Possible WorkArounds 中使用 gremlin 限制重复()步骤仅使用 32 个循环

问题描述

我目前正在使用 Azure Cosmos DB[Gremlin API] 来存储 Hierarichal 信息。我正在使用“ParentOf”类型的边在我的顶点之间维护父子关系。

要求:给定一个已知的父顶点,从该顶点获取所有子顶点[递归派生]。

问题:我正在使用以下查询来获取所需的边和顶点。

获取 vertexX Hierarchy 下的所有顶点: gV().hasLabel('company').has('CompanyName', 'vertexX').emit().repeat(out('ParentOf')).until(__.outE( ).count().is(0))

获取vertexX Hierarchy下的所有边。我们只获取由关系'ParentOf'定义的边:gV().hasLabel('company').has('CompanyName','vertexX').emit().repeat(out ('ParentOf')).until(__.outE().count().is(0)).outE('ParentOf')

问题:给定一个大子距离大于 32 的层次结构,上述查询失败并出现以下错误:gV().hasLabel('company').has('CompanyName','SR101').emit().repeat( out('ParentOf')).until(__.outE().count().is(0)).values('CompanyName'):脚本评估错误:ActivityId:b1f1fc11-f616-4ea4-8301-8e2eb32711d1 ExceptionType: GraphRuntimeException ExceptionMessage:Gremlin 查询执行错误:超过重复()步骤的最大循环数。不能超过 32 个循环。建议使用 times(n) 步骤或使用 loops() 条件限制循环次数。例如:...until(hasId(targetId).or().loops().is(n)) 来源:Microsoft.Azure.Graphs GremlinRequestId:b1f1fc11-f616-4ea4-8301-8e2eb32711d1 上下文:graphcompute 范围:graphcomp -execquery GraphInterOpStatusCode :

我已经尝试过 subgraph() 步骤是否有用,但徒劳无功,因为 cosmosdb 可以使用的 gremlin 步骤有限

看来这是一个限制。对于这种情况,是否有任何已知的最佳实践或解决方法。

标签: azure-cosmosdbazure-cosmosdb-gremlinapi

解决方案


推荐阅读