【发布时间】:2021-01-22 03:37:08
【问题描述】:
我在 Azure CosmosDB 中运行此 Gremlin 查询时遇到问题。
g.V().
has('node', 'id', 'new').
fold().coalesce(
unfold(),
addV('node').
property('id', 'new').
property('partitionKey', 'edd1f6ca3b1c446987d7da29e370cc7e')
).V().
has('node', 'id', 'new').
as('new').
V().
has('node', 'id', 'root').
coalesce(
outE('contains').where(inV().as('new')),
addE('contains').to('new')
).V().
has('node', 'id', 'new').
as('new').
V().has('userGroup', 'id', 'userGroup1').
coalesce(
outE('hasAccess').where(inV().as('new')),
addE('hasAccess').to('new')
)
我遇到了两个问题:
- 如果数据库中有许多其他节点 (350000),则查询超时。我无法在 TinkerPop 中对此进行测试。
- hasAccess 边缘未创建。这适用于 TinkerPop。
查询的基础是(图片来自gremlify.com):
g.addV('node').
property('id', 'root').
property('partitionKey', '33cb2571f8e348eaa875e6a2639af385')
g.addV('userGroup').
property('id', 'userGroup1').
property('partitionKey', '1')
我想最终变成这样:
带有可以多次运行而不更改任何内容的查询(幂等)。如果我在单独的查询中执行此操作,则效果很好:
g.V().
has('node', 'id', 'new').
fold().coalesce(
unfold(),
addV('node').
property('id', 'new').
property('partitionKey', 'edd1f6ca3b1c446987d7da29e370cc7e')
)
g.V().
has('node', 'id', 'new').
as('new').
V().
has('node', 'id', 'root').
coalesce(
outE('contains').where(inV().as('new')),
addE('contains').to('new')
)
g.V().
has('node', 'id', 'new').
as('new').
V().has('userGroup', 'id', 'userGroup1').
coalesce(
outE('hasAccess').where(inV().as('new')),
addE('hasAccess').to('new')
)
但我想保存两个对数据库的调用并一次性完成。
【问题讨论】:
标签: gremlin tinkerpop azure-cosmosdb-gremlinapi