我尝试将数据添加到 cassandra 存储上的现有 janusdb。 我使用 tinkerpop 驱动程序。 通过这种方式,我创建了一个遍历: g = traversal().withRemote(DriverRemoteConnection.using(host,port,"g")); 以这种方式我添加用户 g.addV("User").properties("name",name).hasNext(); 然后我尝试从数据库中恢复用户 g.V().has("name",user).values("name") 但是找不到用户 来自 gremlin 控制台的相同结果 graph.addVertex(label, 'User', 'name', 'ciro2') 如果我在同一会话中搜索用户,我会找到它。如果我关闭会话并重新启动控制台,我找不到用户。 好的,在使用 commit 命令后,数据会保留在数据库中,但只能来自控制台。 graph.tx().commit();

嵌入式解决方案 graph = JanusGraphFactory.open(cassandraConfigPath); g = graph.traversal(); cassandraConfigPath 指向文件的位置 janusgraph-cassandra-es.properties 及其内容: storage.backend=cql storage.hostname=127.0.0.1 cache.db-cache = true cache.db-cache-clean-wait = 20 cache.db-cache-time = 180000 cache.db-cache-size = 0.25 index.search.backend=elasticsearch index.search.hostname=127.0.0.1 index.search.elasticsearch.client-only=true 最后我可以使用这段代码添加一个顶点: g.addV("User").property("name", f).next(); g.getGraph().tx().commit(); 编辑: 感谢 Florian Hockmann 的评论,我也为远程服务器找到了解决方案。当我问这个问题时,我确实使用了 tinkerpop 驱动程序的 3.4.4 版本。这无法加载 conf/remote-objects.yaml 文件。当我将库更新到 3.4.6 时,一切正常。 远程解决方案 g = traversal().withRemote(gremlinServerConfigPath); graph = g.getGraph(); 其中 gremlinServerConfigPath 是 file:///full.qualified.name.properties 和内容 gremlin.remote.remoteConnectionClass=org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection gremlin.remote.driver.clusterFile=conf/remote-objects.yaml gremlin.remote.driver.sourceName=g conf/remote-objects.yaml(资源文件夹下) hosts: [localhost] port: 8182 serializer: { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }} 在这种情况下,提交是不必要的

Did you try that traversal without the commit in the second line with the first method you mentioned in your question, e.g., by connecting withRemote instead of by creating a graph with JanusGraphFactory.open? I think the issue in your original setup was that you used hasNext() instead of next() or iterate(). Otherwise it should work like that.

I have tried many things. Each with a problem. This solution works. Is not it correct in your opinion?

No, your solution is correct, but it's using JanusGraph embedded whereas you have first used JanusGraph Server and connected via withRemote which is the recommended way actually. I wrote about advantages and disadvantages of both approaches in this thread in the janusgrah-users Google group.

In cassandra config I specify remote connection. Why you assert that is embedded?

Ok I understand. I will try this GraphTraversalSource g = traversal().withRemote('conf/remote-graph.properties') for remote ??