Hey, > m = [:]; > g.idx("user").get("key", "%query%*")._()[0..5].sideEffect { x = it.key > }.out.in.uniqueObject.loop(3) { it.loops < 2 }.sideEffect { > if (!m[x]) { m[x] = 0; }; > m[x]++ > } >> -1; > m;
Tips: 1. do g.idx("user").get("key", "%query%*")[0..5] - _() is not needed. 2. use can use single quotes g.idx('user').get('key','%query%*') 3. use groupCount(m) instead of that last sideEffect. > * The [0..5] allows me to page through the index to avoid one massive query. > * I'm thinking perhaps the "aggregate" step would be useful, but I haven't > figured out how to use it yet. aggregate is just a way to collect everything up at a single step before moving to the next step. Typical use case: g.v(1).out('friend').aggregate(x).out('friend').except(x) - my friends' friends who are not my friends. > * I will unroll the loop as Marko suggested when I get to optimizing it Cool. Realize that Gremlin 1.3 (coming out in a couple of weeks) is nearly 2-3x faster on most traversals as we have done many many performance optimizations. However, still unrolling loops will be faster than not doing so. Good luck with your project. Keep the questions/thoughts coming, Marko. http://markorodriguez.com _______________________________________________ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user