'Gremlin - get random query results after filtering

I have the following query:

g.V().
  hasLabel('courseContent').
  has('status', 'active').as('cc').
  outE('ccBelongsToCourse').
  has('status', 'active').
  inV().
  hasLabel('course').
  has('externalId', ':courseId').
  select('cc').by(valueMap('externalId', 'term', 'name')).
  dedup().
  range(:offSet, :limit);

How can I randomize the results I get after filtering by courseId ? I know I can set

g.V().
  hasLabel('courseContent').order().by(shuffle)

But this will reshuffle all the results, I want to randomize only after filtering by courseId and only active nodes. Is that possible ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source