【发布时间】:2020-05-17 15:11:04
【问题描述】:
我正在使用带有以下简单图形架构的 Amazon Neptune:
root --has--> child
根顶点可以有许多不同的属性。
我想要一个查询来创建一个字典,其中包含所有作为键的根顶点属性和一个包含所有具有相同值的子顶点的数组。
例如以下数据:
{
root: {
a: 1
b: 2
c: 3
},
child1: {
a: 4
b: 2
c: 3
},
child2: {
a: 1
b: 4
c: 3
}
}
我会得到以下结果:
{
a: [child2],
b: [child1],
c: [child1, child2]
}
当我知道属性时,我可以这样做:
g.V().hasLabel('Root').as('root')
.project('a', 'b', 'c')
.by(out('has').where(eq('root')).by('a').fold())
.by(out('has').where(eq('root')).by('b').fold())
.by(out('has').where(eq('root')).by('c').fold())
有没有办法在不知道根属性的情况下创建它?
【问题讨论】: