向 JanusGraph 数据库添加数据

Adding data to JanusGraph database

我不得不使用 JanusGraph 从 java 程序中检索数据并向其添加数据。但是我不知道如何连接到 db.Below 的特定图形是我用来在数据库中插入数据的代码但是当我尝试从 gremlin 控制台查看数据时,我找不到相同的数据.

JanusGraph graph = JanusGraphFactory.open("conf/janusgraph-cassandra-es.properties");
GraphTraversalSource g = graph.traversal();

graph.addVertex("psid",psid,"firstname",firstname,"last_name",lastname, "locale", locale ,"timezone",timezone, "gender" ,gender,"channel_id",channel_id);

我正在做的 Gremlin 查询:

gremlin> JanusGraph graph = JanusGraphFactory.open("conf/janusgraph-cassandra-es.properties");
gremlin> GraphTraversalSource g = graph.traversal();
gremlin> g.V().count()

count 查询给出 0 作为输出,我在数据库中找不到任何数据。

添加顶点后是否提交了图形事务?在您不提交事务之前,它会保留在内存实例中并且不会提交给图表。提交使用:

graph.tx().commit()

执行上述代码行后,再次尝试通过gremlin查询图形。您的顶点现在应该在图表上。