我用这个聚合查询来跟踪所有文档,但是这里的问题是光标是有限的,他返回大约500个结果。我试过limit(0)
,但它没有用! ,我也试过限制(10000)或限制(20000),但它没有工作,我总是500结果
AggregateIterable<Document> resultMongo = collection.aggregate(Arrays.asList(
Aggregates.match(and(filters)),
Aggregates.group(and(eq(CoverageWarningFieldEnum.DT_EXTRACT.getLabel(), "$" + CoverageWarningFieldEnum.DT_EXTRACT.getLabel())
, eq(CoverageWarningFieldEnum.ID_SUP_NUMBER.getLabel(), "$" + CoverageWarningFieldEnum.ID_SUP_NUMBER.getLabel())
, eq(CoverageWarningFieldEnum.CODE_SUPPLIER_DLPA_SITE.getLabel(), "$" + CoverageWarningFieldEnum.CODE_SUPPLIER_DLPA_SITE.getLabel())
, eq(CoverageWarningFieldEnum.SUP_NAME.getLabel(), "$" + CoverageWarningFieldEnum.SUP_NAME.getLabel())
, eq(CoverageWarningFieldEnum.MLF07_GRPFOU.getLabel(), "$" + CoverageWarningFieldEnum.MLF07_GRPFOU.getLabel()))
, sum("sum_w_ord_unit_ord_min_coverage", "$" + CoverageWarningFieldEnum.W_ORD_UNIT_ORD_MIN_COVERAGE.getLabel())
, sum("sum_w_excess_delivery", "$*" + CoverageWarningFieldEnum.W_EXCESS_DELIVERY.getLabel())
, sum("sum_w_inventory", "$" + CoverageWarningFieldEnum.W_INVENTORY.getLabel())
, sum("sum_w_service_blocking", "$" + CoverageWarningFieldEnum.W_SERVICE_BLOCKING_2.getLabel())
, sum("sum_w_service_blocking_4", "$w" + CoverageWarningFieldEnum.W_SERVICE_BLOCKING_4.getLabel())
, sum("sum_w_coverage_change", "$" + CoverageWarningFieldEnum.W_COVERAGE_CHANGE.getLabel())
, sum("sum_w_pa_supervision", "$" + CoverageWarningFieldEnum.W_PA_SUPERVISION.getLabel())
, sum("sum_val_pn_stock_total_euro", "$" + CoverageWarningFieldEnum.VAL_PN_STOCK_TOTAL_EURO.getLabel())
, sum("sum_val_pn_average_sale_12month_euro", "$" + CoverageWarningFieldEnum.VAL_PN_AVERAGE_SALE_12MONTH_EURO.getLabel())
, sum("sum_score", "$" + CoverageWarningFieldEnum.SCORE.getLabel())),
Aggregates.sort(Sorts.orderBy(Sorts.descending(CoverageWarningFieldEnum.SCORE.getLabel())))
));
答案 0 :(得分:0)
你做错了。
聚合是一个&#34;组&#34;操作。这就是为什么它将您的结果集分组为500个组。
这清楚地解释了聚合分组https://docs.mongodb.com/manual/aggregation/
如果你想加载所有记录,那么使用mongo&#34; find&#34;操作。 https://docs.mongodb.com/manual/reference/method/db.collection.find/