Gremlin过滤器计数 [英] Gremlin filter by count
本文介绍了Gremlin过滤器计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在CosmosDB Gremlin API中使用此查询:
With the usage of this query in CosmosDB Gremlin API:
g.V().has('person', 'name', 'John').as('his')
.out('bought').aggregate('self')
.out('made_by')
我有下一个输出:
[
{
"id": "100",
"label": "brand",
"type": "vertex",
"properties": {
"name": [
{
"id": "233b77e7-7007-4c08-8930-99b25b67e493",
"value": "Apple"
}
]
}
},
{
"id": "100",
"label": "brand",
"type": "vertex",
"properties": {
"name": [
{
"id": "233b77e7-7007-4c08-8930-99b25b67e493",
"value": "Apple"
}
]
}
},
{
"id": "101",
"label": "brand",
"type": "vertex",
"properties": {
"name": [
{
"id": "f3e238e2-f274-489c-a69c-f1333403ee8e",
"value": "Google"
}
]
}
}
]
有没有办法只选择数量大于1(在这种情况下为Apple)的品牌?
Is there a way to select only brands, which quantity is > 1 (Apple in this case)?
推荐答案
我认为您只需要groupCount()
然后使用过滤器即可:
I think that you just need to groupCount()
and then use a filter:
g.V().has('person', 'name', 'John').as('his').
out('bought').aggregate('self').
out('made_by').
groupCount().
unfold().
where(select(values).is(gt(1))).
select(keys)
您可以先groupCount()
然后unfold()
得到的Map
,以便可以使用where()
过滤条目.
You could just groupCount()
and then unfold()
the resulting Map
so that you can filter the entries with where()
.
这篇关于Gremlin过滤器计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文