I have a graph with 2 different vertex classes with some identical properties.
I need to:
- group all vertices of class Item based on some properties
- find the vertices of class Product that share these properties
g.addV("Item").
property("color", "green").
property("material", "wood").
property("shape", "round").
property("price", 1.2).
addV("Item").
property("color", "green").
property("material", "wood").
property("shape", "round").
property("price", .9).
addV("Item").
property("color", "green").
property("material", "wood").
property("shape", "square").
property("price", 5).
addV("Product").
property("color", "green").
property("material", "wood").next();
What I've tried so far is this
g.V().has("Item", "price", P.inside(0, 10)).
group().
by(project("c", "m").
by("color").by("material")). //\1
local(unfold().
project("color", "material","price","product")
.by(select(Column.keys).select("c"))
.by(select(Column.keys).select("m"))
.by(select(Column.values).unfold().values("price").mean())
.by(
V().hasLabel("Product"). //\2
has("material",P.eq(select(Column.keys).select("c"))).fold()));
I understand that at 2
the scope changes so select(Column.keys)
no longer refers to the group.
However, I'm at a loss how to get the value of the c
(and m
) key into the traversal at 2