Gremlin:按活跃用户与非活跃用户的计数位置生成列表

Gremlin: Generate a list by location of counts for active versus inactive users

我有顶点人物、用户类型和位置。人们有外向的优势 people_location 和 people_usertype。人物有 属性 'name',用户类型有 属性 'activationStatus',位置有 属性 'name'。

我想创建一个如下所示的列表:

[[1]: https://i.stack.imgur.com/lKzZL.png]

我想要按位置统计 activationStatus "active" 和 "inactive" 的人数,其中该位置包含 "US"。

这就是我所有的人数统计,其中 'name' 以美国开头:

g.V()hasLabel('people').out('people_publicisofficelocation')
.filter(has('name',between('US','UT')))
.groupCount().by('name')

它是 运行 但没有产生结果。

您可以在 3.4 之前的 TinkerPop 版本中模拟 'starts with' 行为,使用 has('name',between('US','UT')) 之类的东西,这样您就可以用它替换上面的过滤器行。如果您使用的图形实现支持 TinkerPop 3.4,则还有其他文本谓词可用于开头、结尾和包含。

正如其他人所说,如果您可以 post 一些示例 addV()addE() 构建图表的一部分的步骤,将更容易给出更精确的答案。

这对我有用!

g.V().hasLabel('Location').filter(has('name',between('US','UT'))) .project('Name','Active', 'Inactive', 'Total')  .by('name')  .by(__.both('people_location').out('people_usertype') .where(values('activationStatus').is(eq('Active'))).count())  .by(__.both('people_location').out('people_usertype') .where(values('activationStatus').is(eq('Inactive'))).count())  .by(__.both('people_location').out('people_usertype').count())