【问题标题】:Gremlin group by vertex property and get sum other properties in the same vertexGremlin 按顶点属性分组并获取同一顶点中的其他属性
【发布时间】:2017-12-19 01:59:00
【问题描述】:

我们有顶点可以存储各种作业及其类型和计数作为属性。我必须按状态及其计数进行分组。我尝试了以下适用于一个属性的查询(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 等。有没有更好的方法来提供呢?

【问题讨论】:

    标签: graph datastax-enterprise gremlin tinkerpop tinkerpop3


    【解决方案1】:

    您可以像这样使用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
              ]
            }
          }
        ]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-01-15
      • 1970-01-01
      • 1970-01-01
      • 2019-12-11
      • 1970-01-01
      • 2021-01-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多