In the following query : g.V().has('UID','1233333').as('src').bothE().as('rel').otherV().as('dst').path() : I would like it to return the src if there are no edges to the vertex

53 views
Skip to first unread message

אלה וייס

unread,
May 3, 2016, 8:14:49 AM5/3/16
to Gremlin-users

In case the src vertex has no edges,the above query results with 0 results, but I would like the query to return the src vertex in that case 


Daniel Kuppitz

unread,
May 3, 2016, 8:30:12 AM5/3/16
to gremli...@googlegroups.com
Step labels are unnecessary for this query. You can do this:

g.V().has('UID','1233333').optional(bothE().otherV()).path()

But then you probably have this older version of TP, that tells you, that optional() doesn't exist...

g.V().has('UID','1233333').choose(bothE(), bothE().otherV(), identity()).path()

That's the same.

Cheers,
Daniel


On Tue, May 3, 2016 at 2:14 PM, אלה וייס <ellavs...@gmail.com> wrote:

In case the src vertex has no edges,the above query results with 0 results, but I would like the query to return the src vertex in that case 


--
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/29b7820e-a160-4c0e-b101-24272cb16903%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

אלה וייס

unread,
May 4, 2016, 1:43:44 AM5/4/16
to Gremlin-users
thanks,but how can I add filter or where clouse in order to add condition to get only the vertexes which has more than one edge
g.V().has('UID','1233333').choose(bothE().where(__.bothE().count().is(gt(1))), bothE().where(__.bothE().count().is(gt(1))).otherV(), identity()).path()


I get an error: 

[][.....]Expected traverser of Titan vertex but found  e

בתאריך יום שלישי, 3 במאי 2016 בשעה 15:14:49 UTC+3, מאת אלה וייס:

Daniel Kuppitz

unread,
May 4, 2016, 3:42:31 AM5/4/16
to gremli...@googlegroups.com
You're trying to traverse bothE() from bothE() which, of course, is not possible.
Swap the steps and it should work.

g.V().has('UID','1233333').choose(where(__.bothE().count().is(gt(1))).bothE(), where(__.bothE().count().is(gt(1))).bothE().otherV(), identity()).path()

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.
Reply all
Reply to author
Forward
0 new messages