gremlin - TinkerPop:按边缘计数过滤
问题描述
样本数据:TinkerPop 现代
摘要:我想找到创建了 2 个软件的人。
我从基础开始,并正确计算
g.V().hasLabel("Person").as("from" ,"to1" )
.repeat(bothE().as("e1").otherV().as("to1").dedup("from", "to1")).times(1)
.emit(filter(hasLabel("Software"))).hasLabel("Software")
.group().by(select("from").by("name")).by(count()).as("c")
结果:
>> {'Marko': 1, 'Peter': 1, 'Josh': 2}
所以我尝试应用过滤器但它不起作用(即结果不正确),我尝试了什么:
g.V().hasLabel("Person").as("from")
.repeat(bothE().as("e1").otherV().as("to1").dedup("from", "to1")).times(1)
.filter(bothE().otherV().hasLabel("Software").count(local).is(eq(1)))
.dedup()
.values("name")
知道我在做什么错吗?
样本数据:
解决方案
如果您只需要按边数计算“人”顶点,我真的不明白为什么您需要所有这些repeat()
基础设施。只是:
gremlin> g.V().hasLabel('person').
......1> filter(outE('created').limit(2).count().is(2))
==>v[4]
您只需要计算出边,因为架构是这样的,“创建”标签仅连接到“软件”,因此您不需要检查“软件”顶点标签。您limit(2)
要尽快退出边缘迭代,但不要在您尝试计算 2 条边缘之前退出。
推荐阅读
- angular - ng2-file-upload 多个文件到不同的 URL,但使用相同的 Uploader
- python - 创建多个数据框列,其中包含来自现有列的计算值
- c# - 在 C# 和 iText 7 中使用 x509Certificate2 创建 IExternalSignature
- c# - PDF修改在C#中需要时间
- google-sheets - bigQuery Google Drive 使用 googleSheetsOptions 范围查询多个工作表
- c# - 运行代码时没有出现winform
- reactjs - How can one extend React types to support html attributes as props?
- sass - 如何将 SCSS 十六进制值转换为字符串,以便用于 CSS 类名?
- output - Pi2 GPIO 仅输出 4.7v
- javascript - 有没有办法更有效地扁平化这个承诺链(涉及链式捕获)?