[英]Gremlin - run additional traversal in same query in case not enough values are found
Is there a way to check how many records were found, and in case less than X records were returned do another query?有没有办法检查找到了多少条记录,如果返回的记录少于 X 条,请再次查询?
For example first run this query ->例如首先运行这个查询 ->
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);
And in case less than 10 records were found, run this query:如果找到的记录少于 10 条,请运行以下查询:
g.V().
hasLabel('educatorContent').
has('status', 'active').as('ec').
select('ec').by(valueMap('externalId')).
dedup().
range(:offSet, :limit);
but do it all inside the same .gremlin
file?但是在同一个
.gremlin
文件中完成这一切吗?
(Sorry if the question is too basic, super new to Gremlin) (对不起,如果问题太基本,Gremlin 超级新手)
You could use choose()
which provides if-then semantics:您可以使用提供 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.