【发布时间】:2020-02-13 09:31:10
【问题描述】:
我有一个图,其中包含 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的遍历中
【问题讨论】:
标签: gremlin tinkerpop3