Class Sample

java.lang.Object
dev.morphia.aggregation.stages.Stage
dev.morphia.aggregation.stages.Sample

public class Sample extends Stage
Randomly selects the specified number of documents from its input.
  • Method Details

    • sample

      public static Sample sample(long size)
      Creates a new stage with the given sample size.
      Parameters:
      size - the sample size
      Returns:
      the new stage
      Since:
      2.2
      MongoDB documentation
      Aggregration Pipeline Stage: $sample
      Since server release
      3.2