javaazureazure-cosmosdbgremlinazure-cosmosdb-gremlinapi

How to connect to Azure Cosmos DB Gremlin API via embedded code


For now we are using the very simplified and not near reality approach that Azure officially lets one play: https://learn.microsoft.com/en-us/azure/cosmos-db/gremlin/quickstart-java.

But we need to use gremlin in a scriptive manner ... like this:

g.V().has()...

... not as a string script query that is then submited:

static final String gremlinQueries[] = new String[] {
            "g.addV('person').property('id', 'thomas').as('tom'),
            "g.addV('person').property('id', 'mary').as('may'),
            "g.addE('friends').from('tom').to('may')" };

(...)

for (String query : gremlinQueries) {

   ResultSet results = client.submit(query);
}

for (Result result : resultList) {
   result.toString()
}

I already tried to use Tinkerpop Documentation guides:

https://tinkerpop.apache.org/docs/current/reference/#gremlin-java https://tinkerpop.apache.org/docs/current/reference/#connecting-gremlin


Solution

  • I believe you are asking how to send Gremlin bytecode queries to CosmosDB, but are finding that you can only send strings-based queries. If that is correct, note that CosmosDB does not currently support bytecode based requests, so you are in fact limited to strings. CosmosDB has a long open issue about this here.