I am new to a graph database. I am very sure that the answer should be simple as one or two command lines.
I have very simple schema. Person and Email class. There are edges between Person and Email, SendFrom and SendTo. I want to create edges between Person vertices which is joined by the same email.
For instance, if person A sends an email to person B. I want to create an edge between A and B, and increment count property of the edge.
I tried something like, CREATE EDGE FROM (SELECT in() from Email) TO (SELECT out() from Email)
. Since I am using pyorient, a python driver for OrientDB, this could be done in Python script, or just SQL like language.
I will edit my post, if you need more information. Just let me know.
I tried with this structure
This is the graph.
I used this javascript function.
var g=orient.getGraph();
var c=g.command("sql","select in('SendFrom')[0].@rid as SF, out('SendTo')[0].@rid as ST from email");
for(i=0;i<c.length;i++){
var p1=c[i].getProperty("SF");
var id1=p1.toString();
id1=id1.substring(id1.lastIndexOf("[")+1,id1.lastIndexOf("]"));
var p2=c[i].getProperty("ST");
var id2=p2.toString();
id2=id2.substring(id2.lastIndexOf("[")+1,id2.lastIndexOf("]"));
g.command("sql","create edge e from " + id1 + " to " + id2 );
}
This is the new structure
and this is the new graph
Hope it helps.