@Override public AggregationPipeline bucketAuto(final String field, final int bucketCount, final BucketAutoOptions options) { if (bucketCount < 1) { throw new RuntimeException("bucket count should be more than 0"); } DBObject dbObject = options.toDBObject(); dbObject.put("groupBy", "$" + field); dbObject.put("buckets", bucketCount); stages.add(new BasicDBObject("$bucketAuto", dbObject)); return this; }