在 Gremlin (Cosmos) 中投影 属性 个值的列表

Project a list of of property values in Gremlin (Cosmos)

我在 gremlin 顶点中存储多个值 属性。现在我想在查询中 return 属性 的所有值。

g.AddV('test').property('id','1').property(list,'name','name1')

g.V('1').property(list,'name','name2')

g.V('1').property(list,'name','name3')

当我这样做时 g.V('1') 我得到低于响应。

{
    "id": "1",
    "label": "test",
    "type": "vertex",
    "properties": {
      "name": [
        {
          "id": "de80d819-91ca-4b28-8623-aadf652f0afb",
          "value": "name1"
        },
        {
          "id": "45fd395c-265e-448a-bdbd-7af9b1a3ce57",
          "value": "name2"
        },
        {
          "id": "23a1ee04-0113-4da1-9703-1e9a4f3033e8",
          "value": "name3"
        }
      ]
    }
  }

现在我只想 return name 属性 和 id 的值。预期结果应该如下

[{
    "id": "1",
    "names: : [
         "name1",
         "name2",
         "name3"
   ]
}]

这应该有效:

g.V('1').valueMap(true, 'name')

还有这个:

g.V('1').project('id', 'names')
    .by(id())
    .by(values('name').fold())