Hi,
I'm currently looking into Cypher and Gremlin and I need a little help with grouping in gremlin
in Cypher I write
START n=node(42)
MATCH n-[:FRIEND_OF*1..2]-()<-[r:REVIEWED_BY]-p
RETURN p.title, count(p), sum(r.rating) as h
ORDER BY h DESC;
So, I'd like to know which products where reviewed by my friends and their friends and order them by their rating (which is an edge property).
In Gremlin my first guess was:
m=[:]
v.both('FRIEND_OF').both('FRIEND_OF').inE('REVIEWED_BY').as('r').outV.groupBy(m){it.title}{r.rating.sum()}
But as may already see, the second closure doesn't work as expected because I cannot refer to 'r' again. I also tried to get back to the edges by using {it.outE('REVIEWED_BY').retain(r).rating.sum()} but this didn't work because of the same reason.
A little hint would be very appreciated. Thank you guys in advance.
Martin