Spring data mongodb 在聚合中使用忽略大小写进行排序
我正在尝试使用不区分大小写选项对结果进行排序。这是我的代码:Spring data mongodb 在聚合中使用忽略大小写进行排序,spring-data-mongodb,Spring Data Mongodb,我正在尝试使用不区分大小写选项对结果进行排序。这是我的代码: List<AggregationOperation> operations = new ArrayList<>(); Sort.Order sort = ....ignoreCase(); operations.add(new SortOperation(new Sort(sort))); 我在调试控制台中显示了查询,ignoreCase在聚合中完全消失: db.getCollection('perso
List<AggregationOperation> operations = new ArrayList<>();
Sort.Order sort = ....ignoreCase();
operations.add(new SortOperation(new Sort(sort)));
我在调试控制台中显示了查询,ignoreCase在聚合中完全消失:
db.getCollection('persons').aggregate([
{
"$sort":{
"buyer.organization.name":-1
}
}
])
如何将忽略大小写选项放入聚合中?谢谢你的帮助 解决方案是使用并将其添加到
mongoOperations
中。
我使用了
strength=1
,它忽略了案例。这就是我解决排序问题的方法
val res =
mongoTemplate.aggregate(
aggregations.withOptions(
new AggregationOptions(
false,
false,
null,
Collation.of("en").strength(Collation.ComparisonLevel.primary()))),
Path.class,
CountedAggregationFolderContentDTO.class);
你能举个例子吗?
val res =
mongoTemplate.aggregate(
aggregations.withOptions(
new AggregationOptions(
false,
false,
null,
Collation.of("en").strength(Collation.ComparisonLevel.primary()))),
Path.class,
CountedAggregationFolderContentDTO.class);