Tuesday, 15 September 2015

graph databases - How do I write a sub-query? -



graph databases - How do I write a sub-query? -

i want retrieve vertexes , each 1 want count number of 'like' edges pointing @ it.

how write kind of query in gremlin?

in sql like....

select *, (select count(*) tbl_like l l.id = b.id) likecount tbl_blah b

e.g. utilize sideeffect set counts in map (m)

m=[:];g.v.sideeffect{m[it]=it.ine.has('label','like').count()}

an alternative omits vertices 0 likes:

m=[:];g.v.ine('like').groupcount(m){it.inv.next()}

edit

finally smart solution:

m=[:];g.v.groupcount(m){it}{it.a.ine('like').count()}

the first closure of groupcount determines key update in map , sec closure value key. seems it.a in sec closure gives current input value groupcount (here vertex) , it.b previous value in map input object. haven't found documentation explains this, maybe 1 of tinkerpop guys can elaborate on exact usage of groupcount closures.

graph-databases gremlin titan

No comments:

Post a Comment