简体   繁体   English

在Azure Cosmos DB中使用Gremlin重命名属性

[英]Rename property with Gremlin in Azure Cosmos DB

Some of our codebase has changed, so it now expects the vertices that used to have a property with the name "Sdg" to now have a property with the name "causeType" and with the same value instead.... In short, a renaming of the property. 我们的某些代码库已更改,因此现在希望以前具有名称为“ Sdg”的属性的顶点现在具有名称为“ causeType”且具有相同值的属性。...总之,重命名该财产。

I have tried quite a bit at this point, and... Am a bit surprised of how hard it has been to figure out how to search the graph, and do a renaming when needed. 在这一点上,我已经做了很多尝试,并且...对于找出如何搜索图形以及在需要时进行重命名有多么困难感到有些惊讶。

The closest I have come is the following query: 我最接近的是以下查询:

g.V().has('sdg').as('vertexWithOldProperty').property('causeType', value(select('vertexWithOldProperty').select('sdg')))

...It does not work due to the error: ...由于错误而无法使用:

Gremlin Query Compilation Error: Unable to bind to method 'value', with arguments of type: (GraphTraversal) @ line 1, column 68. Unable to bind to method 'property', with arguments of type: (String) Gremlin查询编译错误:无法绑定到方法'value',参数类型为(GraphTraversal)@第1行,第68列。无法绑定到方法'property',参数类型为(String)

The idea was to run over the graph and remember every vertice that had the old value. 想法是遍历图,并记住具有旧值的每个顶点。 Then I would add the new property with the same value to them... And for simplicity/feasibility I decided to just ignore the old value instead of removing it. 然后,我将具有相同值的新属性添加到它们中。为了简单/可行,我决定忽略旧值,而不是删除它。

Can anyone help me or lead me in the right direction? 谁能帮助我或指引我正确的方向?

Thanks! 谢谢!

Maybe there's a better way, but I think this should work for you: 也许有更好的方法,但是我认为这应该对您有用:

g.V().has('sdg').property('causeType', values('sdg'))

And if you want to delete the old property 如果要删除旧属性

g.V().has('sdg').property('causeType', values('sdg')).properties('sdg').drop()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM