4

We have vertex which will store various jobs and their types and counts as properties. I have to group by the status and their counts. I tried the following query which works for one property(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()

I wanted to give 10 more properties like successCount, FailedCount etc.. Is there a better way to give that?

Sads
  • 557
  • 6
  • 20

1 Answers1

5

You could use cap() step just like:

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

And the result would be:

 "data": [
      {
        "a": {
          "vadas": 1,
          "josh": 1
        },
        "b": {
          "vadas": [
            27.0
          ],
          "josh": [
            32.0
          ]
        }
      }
    ]
John
  • 413
  • 1
  • 5
  • 13