样本数据:TinkerPop现代
摘要:我想找到那些已经创建了两个软件的人。
我从基本知识开始,得到了正确的计数。
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")知道我做错什么了吗?
样本数据:

发布于 2018-05-05 11:13:40
如果您只需要"person“顶点的边计数,我不明白为什么您需要所有的repeat()基础结构。只是:
gremlin> g.V().hasLabel('person').
......1> filter(outE('created').limit(2).count().is(2))
==>v[4]您只需要计算传出边,因为模式使得“已创建”标签只连接到“软件”,因此不需要检查“软件”顶点标签。您可以limit(2)尽可能快地退出边缘迭代,但不是在您尝试计算2条边之前。
https://stackoverflow.com/questions/50098383
复制相似问题