List vertex property names…

2,306 views
Skip to first unread message

Dave vU

unread,
Nov 23, 2016, 1:33:10 AM11/23/16
to Gremlin-users
Apologies if I missed something obvious, but I cannot find a straightforward way to list all the unique property keys (not values) present in a set of vertices. Is there a way to obtain that efficiently?

Additionally: how would one go about doing the same, but with property values (getting a set of unique values present in the vertex selection)?

Thanks in advance!
-- 
Dave

Stephen Mallette

unread,
Nov 23, 2016, 6:07:37 AM11/23/16
to Gremlin-users
You could do something like the following for keys:

gremlin> g.V().hasLabel('person').properties().key().dedup()
==>name
==>age

and the following for values:

gremlin> g.V().hasLabel('person').values().dedup()
==>marko
==>29
==>vadas
==>27
==>josh
==>32
==>peter
==>35

As far as "efficient" key lookup, TinkerPop really doesn't provide anything for that. I'm basically iterating all the person vertices above and popping off the key and getting a unique list. Since TinkerPop doesn't have any notion of a schema, it's not as though you can easily just consult that for an answer. If you were using Titan or DSE Graph you could just ask the "schema object" to give you the keys for some vertex label and that would be "fast".


--
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-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/34841acc-dc66-45b3-beb9-9443d6dfa783%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages