2

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.

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)

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!

oPolo
  • 516
  • 3
  • 14

1 Answers1

4

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()

noam621
  • 2,766
  • 1
  • 16
  • 26
  • 1
    Still had a few problems with running on CosmosDB. It seems it is a pertty small subset of features supported on CosmosDb still, when comparing it to the full language. That being said, I got it solved too - thanks! – oPolo Jul 08 '19 at 08:26