1

我有一个问题。这个查询:

g.V.filter{it.type == 'user'}.outE.filter{it.label == 'follow'}.outV.groupCount().cap()

返回哈希映射

{v[1]=1, v[138]=3, v[140]=3, v[6]=1, v[203]=1, v[619]=7, v[131]=1, v[10]=4, v[192]=1, ...}

如何订购?输出需要为 v[619]=7, v[10]=4,, v[138]=3, v[140]=3, ...

g.V.filter{it.type == 'user'}.outE.filter{it.label == 'follow'}.outV.groupCount().cap().sort{-it.value} not working

谢谢

4

1 回答 1

5

您必须将地图从 cap() 中移出。这是来自 gremlin 终端的示例:

gremlin> g = TinkerGraphFactory.createTinkerGraph()
==>tinkergraph[vertices:6 edges:6]
gremlin> g.V.in.groupCount.cap().sort{-it.value}
==>{v[1]=3, v[6]=1, v[4]=2}
gremlin> g.V.in.groupCount.cap().next().sort{-it.value}
==>v[1]=3
==>v[4]=2
==>v[6]=1
于 2013-01-31T00:43:46.357 回答