Gremlin 按顶点分组 属性 并求和同一顶点中的其他属性

Gremlin group by vertex property and get sum other properties in the same vertex

我们有顶点,它将存储各种作业及其类型和计数作为属性。我必须按状态和他们的计数分组。我尝试了以下查询,它适用于一个 属性(receiveCount)

g.V().hasLabel("Jobs").has("Type",within("A","B","C")).group().by("Type").by(fold().match(__.as("p").unfold().values("receiveCount").sum().as("totalRec")).select("totalRec")).next()

我想再提供 10 个属性,例如 successCount、FailedCount 等。有没有更好的方法来提供它?

您可以像这样使用 cap() 步骤:

g.V().has("name","marko").out("knows").groupCount("a").by("name").group("b").by("name").by(values("age").sum()).cap("a","b")

结果将是:

 "data": [
      {
        "a": {
          "vadas": 1,
          "josh": 1
        },
        "b": {
          "vadas": [
            27.0
          ],
          "josh": [
            32.0
          ]
        }
      }
    ]