azure-cosmosdb - 在 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 步骤有限
看来这是一个限制。对于这种情况,是否有任何已知的最佳实践或解决方法。
解决方案
推荐阅读
- java - Cloud Firestore 使用不必要的小数位保存数字
- angular - 当我选择单选按钮组中的所有单选按钮时,它们都会被选中?
- python - 根据条件更改结构化 numpy 数组列(具有列键)的值
- java - generate scep256k1 public key from private key
- python - 创建与足球比赛时间相关的正则表达式
- core-data - NSPersistentCloudKitContainer: How to check if data is synced to CloudKit
- php - 如何将数组的值推送到laravel中自己的对象项中
- python - 我无法在 html 文件中传递动态数据
- javascript - How to send JSON object message to ActiveMQ using Node JS
- microsoft-teams - Using Microsoft Power Automate to post a reply in a Teams message that contains a particular keyword