Let's say I want to get a few vertices from my database:
g.V(1, 2, 3)
And then I have another set of vertices:
g.V(4, 5, 6)
Imagine it's not just g.V()
, but some more complicated traversal to get my vertices. But the traversal must start with V()
, because I wanna pick from all of my nodes.
Let's also assume I wanna do this multiple times. So I might want to merge 7 different result sets. Each one can have completely different way to get its results.
Now I want to merge these two results into one result set. My first thought was this:
g.V(1, 2, 3).fold().as('x').V(4, 5, 6).fold().as('x').select(all, 'x').unfold()
But this doesn't work. The second call to fold
will clear out my "local variables", because it's a barrier step.
My current attempt is this:
g.V(1, 2, 3).fold().union(identity(), V(4, 5, 6).fold()).unfold()
This works, but looks a bit too complicated. If I wanna repeat it 7 times, it'll make for a very complex query.
Is there a better way to accomplish simple merging of results from two different queries?