我正在与Gremlin一起测试和研究海王星。我创建了一些类型为User的节点,它们仅具有id
和email
。如果我对它们进行原始查询,则会得到:
// http://my-neptune/?gremlin=g.V().hasLabel('User')
"result": {
"data": {
"@type": "g:List",
"@value": [
{
"@type": "g:Vertex",
"@value": {
"id": "u01",
"label": "User",
"properties": {
"email": [
{
"@type": "g:VertexProperty",
"@value": {
"id": {
"@type": "g:Int32",
"@value": 2051025270
},
"value": "User01@email.com",
"label": "email"
}
}
]
}
}
},
{
"@type": "g:Vertex",
"@value": {
"id": "u02",
"label": "User",
"properties": {
"email": [
{
"@type": "g:VertexProperty",
"@value": {
"id": {
"@type": "g:Int32",
"@value": -374298315
},
"value": "user02@mail.com",
"label": "email"
}
}
]
}
}
}
]
}
我不会使用visjs表示此图。因此,我想基本上为每个节点返回3个属性:
id - mail
的格式]为此,我正在执行以下查询:
g.V()
.hasLabel('User')
.project('id', 'label', 'group')
.by(T.id)
.by(
union(id(), values('email'))
.fold()
)
.by(T.label)
但是结果不符合预期。我只对第一个节点获得label
的投影,而对其他节点则为空:
"result": {
"data": {
"@type": "g:List",
"@value": [
{
"@type": "g:Map",
"@value": [
"id",
"u01",
"label",
{
"@type": "g:List",
"@value": [
"u01",
"User01@email.com"
]
},
"group",
"User"
]
},
{
"@type": "g:Map",
"@value": [
"id",
"u02",
"group",
"User",
"label",
{
"@type": "g:List",
"@value": [
// This list should not be empty
]
}
]
}
]
}
关于发生这种情况的任何想法,或者我如何执行类似的任务?
添加答案,以便如果提到的新版本确实解决了问题,则可以接受注释中建议的解决方案。
将Neptune实例升级到https://docs.aws.amazon.com/neptune/latest/userguide/engine-releases-1.0.2.1.R4.html应该可以解决此问题。