Reputation: 12191
I have the following code:
Vertex v = g.addV().property("valueStr", "3").next();
Vertex v2 = g.addV().property("valueStr", "4").next();
Vertex v3 = g.addV().property("valueStr", "5").next();
Edge e = g.V(v.id()).as("a").V(v2.id()).as("b").addE("anEdge").from("a").to("b").property("value", "4").as("e").next();
Edge e2 = g.V(v.id()).as("a").V(v3.id()).as("b").addE("anEdge").from("a").to("b").property("value", "5").as("e").next();
List vertices1 = g.V().match(
__.as("a").hasId(v.id()).outE("anEdge").inV().hasId(v2.id()).as("b"),
__.as("a").hasId(v.id()).outE("anEdge").inV().hasId(v3.id()).as("c")).toList();
System.out.println(vertices1);
List vertices2 = g.V().match(
__.as("a").hasId(v.id()).outE("anEdge").inV().hasId(v2.id()).as("b"),
__.as("a").hasId(v.id()).outE("anEdge").inV().hasId(v3.id()).as("c")).select("a","b").toList();
System.out.println(vertices2);
List vertices3 = g.V().match(
__.as("a").hasId(v.id()).outE("anEdge").inV().hasId(v2.id()).as("b"),
__.as("a").hasId(v.id()).outE("anEdge").inV().hasId(v3.id()).as("c")).select("a").toList();
System.out.println(vertices3);
It is basically node a
connecting to b
, and node a
connecting to c
.
I am doing a match query over this subgraph and each time I return a subset of the elements that were matched..
Here are the outputs:
[{a=v[20], b=v[22], c=v[24]}]
[{a=v[20], b=v[22]}]
[v[20]]
In the first two cases I get a List
of Maps
.. In the last case I get a List
.
How is it possible for the last case to make it also a List
of Maps
or [{a=v[20}]
? I know I can do a hack with select("a","a")
but it seems there should be a cleaner way.
Where does the documentation explain in which cases I will be getting a List
of Vertices
/Edges
, a Map
or a List
of Maps
etc?
Thanks!
Upvotes: 2
Views: 558