Query to get vertices with limit by label

16 views
Skip to first unread message

Yaara Zegelman

unread,
Mar 24, 2022, 9:22:36 AM3/24/22
to Gremlin-users
Hi,
I want to get some vertices, but limit the number of results, to 10 nodes for each label.
I can run:
g.V().group().by(T.label).by(limit(10).fold())
But I only want the vertices without the grouping. How can I do that?

Thanks!!

Stephen Mallette

unread,
Mar 28, 2022, 6:55:49 AM3/28/22
to gremli...@googlegroups.com
you could select() the values of the Map produced by group() and then unfold the resulting Lists from each value:

g.V().group().by(T.label).by(limit(10).fold()).
  select(values).
  unfold().unfold()



--
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/d4f43dfb-4c07-493a-8175-5d907c0d287cn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages