Gremlin:根据活动用户与非活动用户的计数位置生成列表

问题描述 投票:0回答:2

我有顶点人,usertype和位置。人们有外向边缘people_location和people_usertype。人物具有属性“名称”,usertype具有属性“activationStatus”,而location具有属性“name”。

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

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

我希望按位置计算的人数为activationStatus“active”和“inactive”,其中位置中包含“US”。

这就是我只有位置“名称”以美国开头的位置的人数:

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

它正在运行,但没有产生结果。

orientdb gremlin
2个回答
0
投票

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

正如其他人所说,如果你可以发布一些样本addV()addE()步骤来构建你的图形的一部分,那么更容易给出一个更精确的答案。


0
投票

这对我有用!

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())

© www.soinside.com 2019 - 2024. All rights reserved.