【发布时间】:2020-03-26 14:10:24
【问题描述】:
我有一个具有列表属性的顶点,我想替换所述属性中的值并以特定格式投影出结果。 对于上下文,我们假设以下数据:
g.AddV("Post").property("id", "1")
.property(list, "Tags", "gremlin")
.property(list, "Tags", "new")
我希望能够设置Tags 属性。
到目前为止我尝试过的:
g.V("1")
.sideEffect( properties("Tags").drop() )
.property(list, "Tags", "gremlin")
.property(list, "Tags", "closed")
.property(list, "Tags", "solved")
.project("Tags").By(values("Tags"))
我期望的是以下内容
{
"Tags": [
"gremlin",
"closed",
"solved",
]
}
但是我得到了错误Project By: Next: The provided traverser of key "Tags" maps to nothing.
所以看起来好像Tags 属性被完全删除了。
如果我之后做一个查询
g.V("1").project("Tags").By(values("Tags"))
我得到了预期的结果:
{
"Tags": [
"gremlin",
"closed",
"solved",
]
}
所以数据肯定已经改变了。 如果我尝试不投影,则结果包含新值。
g.V("1")
.sideEffect( properties("Tags").drop() )
.property(list, "Tags", "gremlin")
.property(list, "Tags", "closed")
.property(list, "Tags", "solved")
导致:
{
"id": "1",
"label": "Post",
"type": "vertex",
"properties": {
"Tags": [
{
"id": "4eaf5599-511c-4245-aaf8-15c828073fac",
"value": "gremlin"
},
{
"id": "75e3ad96-a503-4608-a675-e28f3ffc2ab4",
"value": "closed"
},
{
"id": "aea1a33c-bd8e-47bb-b294-f01db8642db5",
"value": "solved"
},
]
}
}
但这让我无法预测结果。
我怎样才能既更新数据又进行投影?
我尝试过的其他事情:
- 在
drop()步骤之后添加barrier()步骤无效 - 在
sideEffect()步骤之后添加barrier()步骤无效 - 在
project()步骤之前添加barrier()步骤,无效 - 和上面三个一样,但是用
.fold().unfold()代替,没有用 - 将
project()步骤替换为optional(g.V("1").project("Tags").by(values("Tags")))- 这一步通过重新获取顶点来工作,但成本很高。
【问题讨论】:
标签: azure-cosmosdb gremlin azure-cosmosdb-gremlinapi