![](/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.