Search code examples
consoleazure-cosmosdbgremlinazure-cosmosdb-gremlinapi

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?


Solution

  • I had mixed up the partition key label and value. Reversing these fixed my issue.