jvm MongoDB request DSL • opensavvy.ktmongo.dsl.aggregation.stages • HasSample • sample sample¶ open fun sample(size: Int): Pipeline<Document> Randomly selects size documents. Pipeline optimizations¶ MongoDB is able to perform sampling more efficiently if it is the first stage of the pipeline and size is less than 5% of the collection size. External resources¶ Official documentation See also¶ HasLimit.limit Selects the first elements found.