将数据添加到JanusGraph数据库
问题描述:
我不得不使用JanusGraph从Java程序中检索数据并向其中添加数据。但我不知道如何连接到特定的db.Below图表是我用来在数据库中插入数据的代码,但是当我尝试从gremlin控制台中查看数据时,找不到相同的数据。将数据添加到JanusGraph数据库
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> JanusGraph graph = JanusGraphFactory.open("conf/janusgraph-cassandra-es.properties");
gremlin> GraphTraversalSource g = graph.traversal();
gremlin> g.V().count()
数查询给出0作为输出和我找不到在数据库的任何数据。
答
您是否在添加顶点后执行图形事务?直到你没有提交事务时,它将停留在内存实例中,而不会被提交给图表。提交使用:
graph.tx().commit()
在执行上述代码行后,再次尝试通过gremlin查询图形。您的顶点现在应该在图上。