Starting from the Azure Cosmos DB Graph API example: https://github.com/Azure-Samples/azure-cosmos-db-graph-gremlindotnet-getting-started
I am interested in using Gremlin.NET (the example uses version 3.2.7) to execute queries using the C# classes instead of writing string queries and execute them using the gremlinClient.SubmitAsync<dynamic>("...")
method.
But when I execute the following code I'm getting a
NullReferenceException at Gremlin.Net.Driver.Connection.d__14`1.MoveNext()
when calling .Next()
var gremlinServer = new GremlinServer(hostname, port, enableSsl: true,
username: "/dbs/" + database + "/colls/" + collection,
password: authKey);
var graph = new Graph();
var g = graph.Traversal().WithRemote(new DriverRemoteConnection(new GremlinClient(gremlinServer)));
var vertex = g.V().HasLabel("person").Next();
Console.WriteLine(vertex);
Unfortunately I haven't found any documentation on how to use Gremlin.NET it would be nice if someone of you can point me to some "getting started".
Edit: The query result from the Azure Cosmos DB Data Explorer looks like the following:
[
{
"id": "thomas",
"label": "person",
"type": "vertex",
"properties": {
"firstName": [
{
"id": "9015b584-375f-4005-af00-f49d6e2d6b94",
"value": "Thomas"
}
],
"age": [
{
"id": "c2300d19-12a0-474a-9405-eb89466bcbb3",
"value": 44
}
]
},
"_isRoot": true,
"_isFixedPosition": true
}
]
The reason why this doesn't work with Cosmos DB is simply that Cosmos DB doesn't support Gremlin Bytecode yet which is what is sent to the server when you use the traversal API as you did. So, your only option currently is to really write the queries as strings and just send those query strings to the server.
Regarding documentation: Gremlin traversals can be written in different languages (see The Gremlin Graph Traversal Machine and Language for more information about Gremlin in general). Therefore the TinkerPop docs also apply to Gremlin.Net and the Gremlin.Net part of the documentation only explains the aspects that are really specific to Gremlin.Net.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With