我在与Cosmos一起使用gremlin。以下内容适用于简单查询:
const gremlin = require("gremlin");
const authenticator = new gremlin.driver.auth.PlainTextSaslAuthenticator(
`/dbs/graph/colls/collection`,
"PRIVATE KEY"
);
const client = new gremlin.driver.Client(
"wss://mygraph.gremlin.cosmosdb.azure.com:443/gremlin",
{
authenticator,
mimeType: "application/vnd.gremlin-v2.0+json",
traversalSource: "g"
}
);
client
.submit("g.V()")
.then(function(data) {
console.log(data.toArray());
client.close();
})
.catch(function(err) {
console.log(err);
client.close();
});
但是,当我尝试传递数组参数时:
client
.submit("g.V().has('value', within(arrayParameter))", {
arrayParameter: []
})
我得到答复:
ExceptionType : GraphMalformedException
ExceptionMessage :
Gremlin Malformed Request: Unknown GraphSON type encountered: g:List. Path: 'args.bindings.anArray', Line: 1, Position: 215.
GremlinRequestId : d3513f09-cf89-4d61-b2ac-31dbb60be085
Context : graphcompute
Scope : graphcomp-execquery
GraphInterOpStatusCode : MalformedRequest
HResult : 0x80131500
这在以前的v2客户端上很好用。 Cosmos不支持字节码模式。