JanusGraph adding edge doesn't seem to work


JanusGraph adding edge doesn't seem to work



I am trying to add vertices and edges to JanusGraph and it doesn't seem to work as expected. I am using Cassandra and Elasticsearch as backend. I am able to add vertices. I use code below to test if vertices and edges added.


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



I use code below to add 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();



I changed code to according to Jason's comment below. Now I create new traversal object whenever i want to get existing vertex then add edge. It seems to be working now.


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();





FWIW, works for me as seen in this gist. Any more details you can add to your scenario?
– Jason Plurad
Jun 24 at 19:08





I create single traversal object to add everything do you think that would make difference what kind of details should i supply thank you so much
– DreadfulWeather
Jun 24 at 19:17





a full example would be helpful, like I showed in my gist
– Jason Plurad
Jun 25 at 12:55









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

how to run turtle graphics in Colaboratory

Export result set on Dbeaver to CSV