How to change the following query in orer to get the results in x: and y:

22 views
Skip to first unread message

אלה וייס

unread,
May 3, 2016, 3:10:32 AM5/3/16
to Gremlin-users

g.V().or()(__.has('uid',within(1,2,3,4)).as('x'),__.has('uid',within(5,6,7,8)).as('y')

I would like to get the result :

x:[v[324544],v[454545],v[564564],v[768888]]
y:[v[444433],v:[7656757],v[834545],v[234244]] 

but I get :

v[324544]
v[454545],
v[564564
v[768888
.......


when I put in the end select('x','y')

It did not work

Daniel Kuppitz

unread,
May 3, 2016, 3:18:42 AM5/3/16
to gremli...@googlegroups.com
.as(<label>) doesn't collect / aggregate elements. Try this:

g.V().has('uid',within(1,2,3,4)).aggregate('x').limit(1).
  V().has('uid',within(5,6,7,8)).aggregate('y').cap('x','y')

It will return the expected result as long as at least one "x" exists.

Cheers,
Daniel


--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/485d1fea-a7be-42cb-a02c-8cfdd9c28f74%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Daniel Kuppitz

unread,
May 3, 2016, 3:23:57 AM5/3/16
to gremli...@googlegroups.com
This one will also work if no "x" exists:

g.V().has('uid',within(1,2,3,4,5,6,7,8)).
  choose(has('uid',within(1,2,3,4)), store('x'), store('y')).cap('x','y')

Cheers,
Daniel

Reply all
Reply to author
Forward
0 new messages