mongo聚合字符串类型的数字进行排序

  • 设置collation
Collation collation = Collation.of(Locale.CHINESE)
                .numericOrdering(true);
  • 设置聚合选项
Aggregation aggregation = Aggregation.newAggregation(
                Aggregation.match(orOperator),

        ).withOptions(AggregationOptions.builder()
                        .collation(collation)
                .build());
posted @ 2023-06-14 20:02  java渣渣  阅读(68)  评论(0编辑  收藏  举报