ajs*_*ajs 4 java gremlin janusgraph java-11
我一直在尝试在 docker 中与我的 JanusGraph 设置进行交互。但经过多次尝试我仍然没有成功。
我如何连接到 JG。
public boolean connect() {
try {
graph = traversal().withRemote("path/to/janusgraph-cql-lucene-server.properties");
return true;
} catch (Exception e) {
log.error("Unable to create connection with graph", e);
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
我如何尝试添加顶点。看起来这并没有什么作用。
GraphTraversal<Vertex, Vertex> yt = graph.addV("link")
.property("url", "https://www.youtube.com/123")
.property("page_type", "contact");
GraphTraversal<Vertex, Vertex> fb = graph.addV("link")
.property("url", "https://www.facebook.com/456");
graph.tx().commit();
Run Code Online (Sandbox Code Playgroud)
System.out.println(graph.V().hasLabel("link").count().next()); //returns 1 (the node I added manually)
Run Code Online (Sandbox Code Playgroud)
我的假设:
我唯一不确定的是是否缺少我的事务提交。除了我没找到其他的graph.tx().commit();
你能帮助我并告诉我我做错了什么吗?
GraphTraversal 对象只是一个要执行的“计划”。要使其生效,您需要一个关闭方法,如 next、toList 等,就像您对计数所做的那样。
造成混乱的原因可能是 gremlin 控制台自动按照配置的次数继续进行接下来的遍历。