How to get only the id and label from a vertex?

108 views
Skip to first unread message

Yaara Zegelman

unread,
Sep 12, 2022, 4:49:55 AM9/12/22
to Gremlin-users
Hi, I want to query only the id and label from a vertex, no need for other properties. What is the most efficient query to do that?

I'm using Neptune if that helps.

Thank!

Aparna Joshi

unread,
Sep 12, 2022, 5:23:14 AM9/12/22
to gremli...@googlegroups.com
Is this what you are looking for? I am using janus ... Hopefully
should work for Neptune as well...

gremlin> :> g.V().elementMap('id','label').limit(1);
==>{id=3153924320, label=entityData}
> --
> 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/11a12535-ce85-4451-b1fa-5461afc23709n%40googlegroups.com.

Daniel Craig

unread,
Sep 12, 2022, 10:54:20 AM9/12/22
to Gremlin-users
Beat me to it :) that works on Neptune as well, just tested it myself

Kelvin Lawrence

unread,
Sep 26, 2022, 11:49:43 AM9/26/22
to Gremlin-users
Please note that elementMap('id','label') may not be doing what you think it does. Those would actually be treated as property keys. If they don't exist you will just get the actual ID and Label returned. You would see the same thing if you did elementMap('x') assuming there is no property called 'x'

Daniel Craig

unread,
Oct 7, 2022, 11:42:00 AM10/7/22
to Gremlin-users
Oh thanks for clarifying this, I didn't know that
Reply all
Reply to author
Forward
0 new messages