graph-databases - 查询返回错误值
问题描述
我正在和 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
- 标签(显示在节点中,我想要类似的格式
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应该可以解决该问题。
推荐阅读
- python - Kivy - 如何从 Urlrequest on_progress / 屏幕刷新更新标签
- wcf - WCF 获得有意义的通道异常
- r - replace_emoticon 函数错误地替换单词中的字符 - R
- azure - 如何降低 Azure Web 应用临时文件的使用率
- java - com.ibm.db2.jcc.am.SqlException:[jcc][10150][10300][3.67.28] 无效参数:未知列名 DeliverAge。错误代码=-4460,SQLSTATE=null
- javascript - 使用 Express 和 MongoDB - 如何注销用户?
- nuxt.js - 如何在 Nuxt 初始化状态存储之前执行代码?
- coreml - CreateML Recommender 训练错误:推荐模型中的项目 ID 必须编号为 0、1、...、num_items - 1
- sql - 获取SQL(oracle)中每个类别的最大值
- flutter - 如何将具有时间戳字段的firestore doc数据转换为通过Freezed dart包生成的数据类?