繁体   English   中英

JanusGraph添加边缘似乎不起作用

[英]JanusGraph adding edge doesn't seem to work

我正在尝试向JanusGraph添加顶点和边,但它似乎没有按预期工作。 我正在使用Cassandra和Elasticsearch作为后端。 我能够添加顶点。 我使用下面的代码测试是否添加了顶点和边。

this.graph = JanusGraphFactory.open("conf/janusgraph-cassandra-es.properties");
trv = graph.traversal()
trv.V().count()
//Returns count and runs as expected
trv.E().count()
//Returns 0 even though I added the edges

我使用下面的代码添加边缘。

tx = this.graph.newTransaction();
Long vertexId = companyMap.get(Integer.parseInt(record.get("ASSIGNEE")));
Vertex assignee = this.traversal.V(vertexId).next();
Vertex patent = this.traversal.V(patentId).next();
patent.addEdge("assigned_to", assignee);
tx.commit();

我根据杰森下面的评论更改了代码。 现在,只要我想获取现有顶点然后添加边,就可以创建新的遍历对象。 它现在似乎正在工作。

GraphTraversalSource trv = this.graph.traversal();
Long vertexId = companyMap.get(Integer.parseInt(record.get("ASSIGNEE")));
Vertex assignee = this.traversal.V(vertexId).next();
Vertex patent = this.traversal.V(patentId).next();
patent.addEdge("assigned_to", assignee);
trv.tx().commit();

使用最新的janusgraph 0.3.x版本,其中包括不同后端的用法示例

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM