【发布时间】:2019-11-07 11:48:58
【问题描述】:
我必须输入顶点 Country 和 Airports,每个国家/地区对多个带有标签“hasAirport”的机场都有优势
我正在尝试加入查询,该查询将返回按其拥有的机场分组的国家/地区。
g.V().hasLabel("Country").as("country").out('hasAirport').as("airport").select("country", "airport").by(__.unfold().valueMap(true).fold()).toList()
如果我的图表中只有一个国家说美国有两个机场,则查询结果如下所示。
[ {
"country": [
{
"name": "United States",
"code": "USA", "label": "Country",
"id": 1565,
}
],
"airport": [
{
"id": 1234,
"label": "Airport",
"name": "San Francisco International Airport", "code": "SFO"
}
] }, {
"country": [
{
"name": "United States",
"code": "USA", "label": "Country",
"id": 1565,
}
],
"airport": [
{
"id": 2345,
"label": "Airport",
"name": "Austin Bergstrom International Airport", "code": "AUS"
}
] } ]
有没有办法将多个机场组合成一个数组,如下所示
[
{
"country": [
{
"name": "United States",
"code": "USA",
"label": "Country",
"id": 1565,
}
],
"airport": [
{
"id": 1234,
"label": "Airport",
"name": "San Francisco International Airport",
"code": "SFO"
},
{
"id": 2345,
"label": "Airport",
"name": "Austin Bergstrom International Airport",
"code": "AUS"
}
]
}
]
【问题讨论】:
标签: java gremlin tinkerpop amazon-neptune