Let us suppose I have apples which come from trees on various farms. So trees bear apples, and farms have trees. I want a list of apples which also contain a reference to the farm they come from.
g = new TinkerGraph();
// apples
a1 = g.addVertex("a1");
a1.setProperty("type", "apple");
a2 = g.addVertex("a2");
a2.setProperty("type", "apple");
a3 = g.addVertex("a3");
a3.setProperty("type", "apple");
// trees
t1 = g.addVertex("t1");
t1.setProperty("type", "tree");
t2 = g.addVertex("t2");
t2.setProperty("type", "tree");
// farms
f1 = g.addVertex("f1");
f1.setProperty("type", "farm");
f1.setProperty("uid", "f1");
f2 = g.addVertex("f2");
f2.setProperty("type", "farm");
f2.setProperty("uid", "f2");
g.addEdge(t1, a1, "bears");
g.addEdge(t1, a2, "bears");
g.addEdge(t2, a3, "bears");
g.addEdge(f1, t1, "has");
g.addEdge(f2, t2, "has");
I want to traverse and the graph to report each apple, and also include the farm id in it. I tried something like this:
g.V.has("type", "apple").copySplit(_().in("bears").in("has").map("uid"),
_().map()).fairMerge
The output I get is:
==>{uid=f1}
==>{type=apple}
==>{uid=f1}
==>{type=apple}
==>{uid=f2}
==>{type=apple}
What I want is:
==>{uid=f1, type=apple}
==>{uid=f1, type=apple}
==>{uid=f2, type=apple}