我对groupCount和使用生成的节点执行更多查询感到有点困惑。我一直在Neo4j控制台中执行此操作。例如,使用TinkerGraph数据集:
gremlin> g = TinkerGraphFactory.createTinkerGraph()
==> tinkergraph[vertices:6 edges:6]
gremlin> g.V.getClass()
==> class com.tinkerpop.gremlin.groovy.GremlinGroovyPipeline
gremlin> m = [:]
gremlin> g.V.out.groupCount(m)
==> v[2]
==> v[4]
==> v[3]
==> v[3]
==> v[5]
==> v[3]
gremlin> m
==> v[2]=1
==> v[4]=1
==> v[3]=3
==> v[5]=1
gremlin> m.getClass()
==> class java.util.LinkedHashMap
gremlin> m = m.keySet()
==> v[2]
==> v[4]
==> v[3]
==> v[5]
gremlin> m.getClass()
==> class java.util.HashMap$KeySet
gremlin> m.outE
==> [StartPipe, OutEdgesPipe]
==> [StartPipe, OutEdgesPipe]
==> [StartPipe, OutEdgesPipe]
==> [StartPipe, OutEdgesPipe]
gremlin> m.outE.map
==> [StartPipe, OutEdgesPipe, PropertyMapPipe]
==> [StartPipe, OutEdgesPipe, PropertyMapPipe]
==> [StartPipe, OutEdgesPipe, PropertyMapPipe]
==> [StartPipe, OutEdgesPipe, PropertyMapPipe]如何将m用作GremlinGroovyPipeline对象?我期待一个类似于下面这样的结果:
gremlin> m.outE
==> e[7][1-knows->2]
==> e[8][1-knows->4]
==> e[9][1-created->3]
==> e[12][6-created->3]
==> e[10][4-created->5]
==> e[11][4-created->3]发布于 2012-06-26 14:48:46
我在一个与这个问题完全无关的论坛帖子上随机找到了答案。
尽管如此,答案还是在这里:
gremlin> m.keySet()_().outE.map
==> {weight=1.0}
==> {weight=0.4}只需在keySet()方法调用后添加文本_(),似乎就可以将其直接转换回GremlinGrrovyPipeline对象:
gremlin> m.keySet()_().getClass()
==> class com.tinkerpop.gremlin.groovy.GremlinGroovyPipelinehttps://stackoverflow.com/questions/11200124
复制相似问题