Reputation: 35621
I am trying to set properties on a vertex in a partitioned CosmosDB graph. If the vertex had any properties previously, I want them scrubbed and replaced with the new set of properties.
Even the deleting was a bit tricky, as the 'partition key' is exposed as a non-deleteable property.
g.V('nodeId').has('partitionKey','xx').properties().drop()
-> "Gremlin Query Execution Error: The partition property cannot be removed."
Fortunately, the id
of the partition key property is predictable and can be used for filtering it out:
g.V('nodeId').has('partitionKey','xx')
.properties().not(has('id', 'nodeId|partitionKey'))
.drop()
Now I'm stuck trying to add the new properties. I tried:
g.V('nodeId').has('partitionKey','xx')
.properties().not(has('id', 'nodeId|partitionKey'))
.drop()
.property('a','valA')
.property('b','valB')
but that looks like I'm applying the property()
step to a (empty) list of properties, not to a vertex.
The error isn't very helpful:
Gremlin Query Compilation Error: Column reference R_200324["_value"] cannot be located in the raw records in the current execution pipeline.
I tried using applying the property()
step to the vertex (by select
-ing it), but I must be doing something wrong:
g.V('nodeId').has('partitionKey','xx')
.as('v')
.properties().not(has('id', 'nodeId|partitionKey'))
.drop()
.select('v')
.property('a','valA')
.property('b','valB')
This gives the same error as above.
I also tried .back('v')
instead of .select('v')
but it looks like back
is not supported in CosmosDB.
Any suggestions?
Upvotes: 2
Views: 1666
Reputation: 10019
I think you are running into the same problem as described in this S.O. answer.
Basically, the .drop()
filters everything out of the traversal and prevents any of the following code from doing anything.
You can work around this by using .sideEffect()
like so
g.V('nodeId').has('partitionKey','xx')
.sideEffect(properties().not(has('id', 'nodeId|partitionKey')).drop())
.property('a','valA')
.property('b','valB')
Upvotes: 2