Gremlin组通过顶点属性并在同一个顶点中获得其他属性的总和 [英] Gremlin group by vertex property and get sum other properties in the same vertex

查看:411
本文介绍了Gremlin组通过顶点属性并在同一个顶点中获得其他属性的总和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

$ $ $ $ $ $ $ $ gV()。hasLabel(Jobs)。has 类型,( A, B, C))内。组()。由( 类型)。由(倍()。匹配(__。如( p)。展开( ).values(receiveCount)。sum()。as(totalRec))。select(totalRec))。next()

我想给出10个更多的属性,如successCount,FailedCount等等。有没有更好的方法来给出这个?

解决方案您可以使用 cap()步骤:

其结果是:
$ b $ p $ data $:$ $ $ b {
a:{
vadas:1,
josh:1
},
b:{
vadas:[
27.0
],
josh:[
32.0
]
}
}
]


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?

解决方案

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 ] } } ]

这篇关于Gremlin组通过顶点属性并在同一个顶点中获得其他属性的总和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆