4
votes

According to cosmosDB graph documentation, a vertex can have property with multiple values. https://docs.microsoft.com/en-us/azure/cosmos-db/gremlin-support

So while adding vertex if we define multiple values for a property, it gets added.

Suppose my query is :

g.addV('employee').property('id', 'john').property('country', 'USA').property('country', 'India')

Result is:

[{"id":"john","label":"employee","type":"vertex","properties":{"country":
    [{"id":"5dc2aaf6-cb11-4d4a-a2ce-e5fe79d28c80","value":"USA"},
     {"id":"fcf4baf6-b4d5-45a3-a4ba-83a859806aef","value":"India"}]}}] 

But while updating vertex, if we update a property with multiple values.

Query is:

g.V('john').property('country', 'USA').property('country', 'India').property('country', 'China')

Result is:

[{"id":"john","label":"employee","type":"vertex","properties":{"country":
    [{"id":"7e5d9847-31e5-4a59-82f9-b78e744420a1","value":"China"}]}}]

How to update this property with multiple values?

1

1 Answers

7
votes

You're missing the list keyword that will allow you to add additional properties.

I'd recommend reading the Tinkerpop docs on VertexProperties

g.V('john').property(list, 'country', 'USA')
   .property(list, 'country', 'India')
   .property(list, 'country', 'China')