简体   繁体   中英

CosmosDB Graph: How to update vertex having property with multiple values using gremlin?

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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