Mongo遇到 Overflow sort stage buffered data usage of ? bytes exceeds internal limit of ?

来源:互联网 发布:淘宝卖steam游戏 编辑:程序博客网 时间:2024/06/05 09:39

Mongo遇到了如上的问题。一开始以为是索引的问题(应该确实是索引的问题),所以代码如下:

String sortField=condition.getSort();if (StringUtils.isNotBlank(sortField)){IndexOperations indexOps=mongoTemplate.indexOps(MyDO.class);Index index=new Index();index.on(sortField,Direction.ASC);indexOps.ensureIndex(index);}List<MyDO.class> elements=mongoTemplate.find(query,MyDO.class);long total=mongoTemplate.count(query,MyDO.class);

加上之后后来又遇到了这个问题,调研后才发现,这个index.on()的第一个参数key,应该是MyDO.class里面的@Field字段,而不是pojo的字段。更改后目前是好用的。

0 0
原创粉丝点击