![](/img/trans.png)
[英]Gremlin query how to compare properties of edges in same branch of my traversal?
[英]Gremlin - run additional traversal in same query in case not enough values are found
有没有办法检查找到了多少条记录,如果返回的记录少于 X 条,请再次查询?
例如首先运行这个查询 ->
g.V().
hasLabel('courseContent').
has('status', 'active').as('cc').
outE('ccBelongsToCourse').
has('status', 'active').
inV().
hasLabel('course').
has('externalId', ':courseId').
select('cc').by(valueMap('externalId')).
dedup().
range(:offSet, :limit);
如果找到的记录少于 10 条,请运行以下查询:
g.V().
hasLabel('educatorContent').
has('status', 'active').as('ec').
select('ec').by(valueMap('externalId')).
dedup().
range(:offSet, :limit);
但是在同一个.gremlin
文件中完成这一切吗?
(对不起,如果问题太基本,Gremlin 超级新手)
您可以使用提供 if-then 语义的choose()
:
range(:offSet, :limit).fold().
choose(count(local).is(gt(9)),
identity(),
V().has('educatorContent', 'status','active')....)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.