Substring in Gremlin

328 views
Skip to first unread message

Vikram Shelke

unread,
Dec 17, 2019, 5:47:25 AM12/17/19
to Gremlin-users
Hi Guys,

How can I substring the value return by my gremlin query in query itself?

Eg. String return by my query is like below,
/abcd/123/qwerty

I want data before second slash and after first slash in the output i.e abcd


Thanks in advance!

Stephen Mallette

unread,
Dec 18, 2019, 6:38:19 AM12/18/19
to gremli...@googlegroups.com
There is no substring() in Gremlin at this time. You would have to use a lambda unfortunately:

gremlin> g.V().values('name').map{it.get().substring(1,2)}
==>a
==>a
==>o
==>o
==>i
==>e

--
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/d3c58c04-1ebc-4a9c-a8ab-4dec9890660f%40googlegroups.com.

Vikram Shelke

unread,
Dec 18, 2019, 7:39:20 AM12/18/19
to Gremlin-users
Thanks Stephen.
Very useful!
Reply all
Reply to author
Forward
0 new messages