在 gremlin 中获取分组后的值?

Get the value after group by in gremlin?

g.V('JobDefinition1').out("JobDefinitionToJobHistory").has("Timestamp", between("2022-02-01T00:00:00Z", "2022-02-03T00:00:00Z")).group().by("ttl").by(limit(1))

我在上面有一个 gremlin 查询并得到下面的结果。

[
  {
    "776": [
      {
        "id": "JobHistory-2-1-2022 12:19:15 AM",
        "label": "JobHistory",
        "type": "vertex",
        "properties": {
          "Timestamp": [
            {
              "id": "6d187ccf-160d-4d87-a360-48526b7a1461",
              "value": "2022-02-01T00:00:00Z"
            }
          ],
          "ttl": [
            {
              "id": "JobHistory-2-1-2022 12:19:15 AM|ttl",
              "value": "776"
            }
          ]
        }
      }
    ],
    "888": [
      {
        "id": "JobHistory-2-1-2022 12:19:15 AM",
        "label": "JobHistory",
        "type": "vertex",
        "properties": {
          "Timestamp": [
            {
              "id": "6d187ccf-160d-4d87-a360-48526b7a1461",
              "value": "2022-02-01T00:00:00Z"
            }
          ],
          "ttl": [
            {
              "id": "JobHistory-2-1-2022 12:19:15 AM|ttl",
              "value": "888"
            }
          ]
        }
      }
    ]
  }
]

但是我只想得到group by后结果的值,异常结果如下图。我想要没有键的 groupby 结果值(如您所见,例外结果没有键信息,如“776”和“888”)。有没有什么 gremlin 方法可以帮助我实现这个目标。希望你能给我一些帮助。谢谢!

[
  {
    "id": "JobHistory-2-1-2022 12:19:15 AM",
    "label": "JobHistory",
    "type": "vertex",
    "properties": {
      "Timestamp": [
        {
          "id": "6d187ccf-160d-4d87-a360-48526b7a1461",
          "value": "2022-02-01T00:00:00Z"
        }
      ],
      "ttl": [
        {
          "id": "JobHistory-2-1-2022 12:19:15 AM|ttl",
          "value": "776"
        }
      ]
    }
  }
  ,
  {
    "id": "JobHistory-2-1-2022 12:19:15 AM",
    "label": "JobHistory",
    "type": "vertex",
    "properties": {
      "Timestamp": [
        {
          "id": "6d187ccf-160d-4d87-a360-48526b7a1461",
          "value": "2022-02-01T00:00:00Z"
        }
      ],
      "ttl": [
        {
          "id": "JobHistory-2-1-2022 12:19:15 AM|ttl",
          "value": "888"
        }
      ]
    }
   }
]

您可以使用 select(values)Map 获取值:

gremlin> g.V().groupCount().by(label)
==>[software:2,person:4]
gremlin> g.V().groupCount().by(label).select(values)
==>[2,4]