Sample data: TinkerPop Modern Graph
Conditions:
- Is
vadas
connected tolop
within2 hops
- Is
vadas
connected topeter
within3 hops
- Is
vadas
connected todoes-not-exists
in1 hops
(a search that wont give any results)
Dummy searches with expected results
Conditions
1
AND2
=> [vadas-marko-lop, vadas-marko-lop-peter]Conditions
1
OR3
=> [vadas-marko-lop]
What I was able to get
- Conditions
1
AND2
gremlin> g.V().has("person", "name", "vadas").as("from")
.select("from").as("to1").repeat(both().as("to1")).times(2).emit().has("software", "name", "lop")
.select("from").as("to2").repeat(both().as("to2")).times(3).emit().has("person", "name", "peter")
.project("a", "b")
.by(select(all, "to1").unfold().values("name").fold())
.by(select(all, "to2").unfold().values("name").fold())
==>[a:[vadas,marko,lop],b:[vadas,marko,lop,peter]]
- Conditions
1
OR2
gremlin> g.V().has("person", "name", "vadas").as("nodes")
.union(repeat(both().as("nodes")).times(2).emit().has("software", "name", "lop"),
out().has("x", "y", "does-not-exist").as("nodes"))
.project("a")
.by(select(all, "nodes").unfold().values("name").fold())
==>[a:[vadas,marko,lop]]
So how to achieve this I have two different query formats, is there a way to writer a query format that can do both?
And this did not work, anything wrong here? Does not return the nodes that have been traversed
g.V().has("person", "name", "vadas").as("nodes")
.or(
repeat(both().as("nodes")).times(2).emit().has("software", "name", "lop"),
repeat(both().as("nodes")).times(3).emit().has("person", "name", "peter")
)
.project("a").by(select(all, "nodes").unfold().values("name").fold())
==>[a:[vadas]]
// Expect paths to be printed here vadas..lop, vadas...peter