我有一个包含2种不同顶点类别及一些相同属性的图。
我需要:
- 根据某些属性将所有属于Item类的顶点分组
- 找到与这些属性相同的Product类顶点
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();
我尝试过的方法如下:
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()));
我理解在
2
处范围发生变化,因此select(Column.keys)
不再引用该组。
但是,我不知道如何将c
(和m
)键的值传递到2
处的遍历中。
next
。 - Denis Kirchhübel