Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert vertex into local Cosmos DB Emulator using Gremlin Console

I am trying to add vertices (and eventually edges) to a local Cosmos DB graph using the Gremlin console. I've been following this tutorial. However, whenever I try to add a vertex, I get an error about the partition key.

My query:

g.addV('person').property('firstName', 'Thomas').property('lastName', 'Andersen').property('age', 44).property('userid', 1).property('pk', 'pk')

The error:

ActivityId : cd07f7be-d824-40fa-8137-0f2726a9c26d
ExceptionType : GraphRuntimeException
ExceptionMessage :
Gremlin Query Execution Error: Cannot add a vertex where the partition key property has value 'null'.
Source : Microsoft.Azure.Cosmos.Gremlin.Core
GremlinRequestId : cd07f7be-d824-40fa-8137-0f2726a9c26d
Context : graphcompute
Scope : graphcomp-execquery
GraphInterOpStatusCode : GraphRuntimeError
HResult : 0x80131500
Type ':help' or ':h' for help.
Display stack trace? [yN]

How can I fix my query and insert the data?

like image 535
jkost4 Avatar asked Dec 15 '25 05:12

jkost4


1 Answers

Did the same mistake of mixing the two values up. So when you add your azure database, you have to specify a partition key, I picked '/client';

Now when I do my query, I have to add this property:

.property('client', 'pk')

-- the first value has to be the key itself, and the second one 'pk', short for 'partitionKey'; Then in your document you have to add a property:

client: 'TESTCLIENTID'

But again, a lot of this is about what your 'partitioning' strategy is based on, which is something you have to decide upfront for each collection, this video from Azure explains things in more detail quite good.

like image 129
SebastianG Avatar answered Dec 16 '25 21:12

SebastianG



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!