Azure cosmosdb 使用遍历查询Azure Cosmos数据库图
我尝试使用遍历来查询Azure Cosmos DB图,如下所示Azure cosmosdb 使用遍历查询Azure Cosmos数据库图,azure-cosmosdb,Azure Cosmosdb,我尝试使用遍历来查询Azure Cosmos DB图,如下所示 val cluster = Cluster.build(File("remote.yaml")).create() val client = cluster.connect() val graph = EmptyGraph.instance() val g = graph.traversal().withRemote(DriverRemoteConnection.using(cluster)) val traversal = g
val cluster = Cluster.build(File("remote.yaml")).create()
val client = cluster.connect()
val graph = EmptyGraph.instance()
val g = graph.traversal().withRemote(DriverRemoteConnection.using(cluster))
val traversal = g.V().count()
val aliased = client.alias("g")
val result = aliased.submit(traversal)
val resultList = result.all().get()
resultList.forEach { println(it) }
问题是在result.all().get()之后执行挂起,并且从未得到响应。我只有在提交遍历时才遇到这个问题。当直接提交一个Gremlin查询字符串时,它工作正常。我也在一条类似的船上,但根据这条最近的查询,目前还不可能进行遍历。然而,对于那些使用(或考虑使用)Gremlin.NET连接到Cosmos的人,我将分享一些我能够做的事情 首先,我在使用gremlin.NET时,从gremlin控制台连接到cosmos没有问题,如下所示:
var gremlinServer = new GremlinServer(hostname, port, enableSsl: true,
username: "/dbs/" + database + "/colls/" + collection,
password: authKey);
var driver = new DriverRemoteConnection(new GremlinClient(gremlinServer));
//var driver = new DriverRemoteConnection(new GremlinClient(new GremlinServer("localhost", 8182)));
var graph = new Gremlin.Net.Structure.Graph();
var g = graph.Traversal().WithRemote(driver);
g.V().Drop().Next(); // nullreferenceexception
当使用Gremlin.NET与本地托管的Gremlin服务器一起工作时(请参见注释行),一切都可以正常工作
使用gremlin.net处理cosmos的唯一方法是以字符串文本形式提交查询,例如
var task = gremlinClient.SubmitAsync<dynamic>("g.V().Drop()");
var task=gremlinClient.SubmitAsync(“g.V().Drop()”);
这是可行的,但我希望能够使用流畅的遍历
我可以使用Azure/Graph API(documentclient等)非常轻松地使用Cosmos,但仍然只能使用字符串文本。而且,这不是很便携,而且