- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在mongoDB中我想按顺序获得结果,但是当我使用排序方法时,出现错误
com.mongodb.MongoQueryException: Query failed with error code 96 and error message 'Executor error during find command :: caused by :: Sort operation used more than the maximum 33554432 bytes of RAM. Add an index, or specify a smaller limit.' on server localhost:27017 at com.mongodb.operation.FindOperation$1.call(FindOperation.java:722) at com.mongodb.operation.FindOperation$1.call(FindOperation.java:711) at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:471) at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:415) at com.mongodb.operation.FindOperation.execute(FindOperation.java:711) at com.mongodb.operation.FindOperation.execute(FindOperation.java:83) at com.mongodb.Mongo$3.execute(Mongo.java:826) at com.mongodb.MongoIterableImpl.execute(MongoIterableImpl.java:130) at com.mongodb.MongoIterableImpl.iterator(MongoIterableImpl.java:77) at com.linkyoyo.wmlink.service.impl.DataShowServiceImpl.getAllDateRWDByTowerId(DataShowServiceImpl.java:42) at com.linkyoyo.wmlink.service.impl.DataShowServiceImpl.getSpeedDateRWDByTowerId(DataShowServiceImpl.java:49) at com.linkyoyo.wmlink.service.impl.DataShowServiceImpl$$FastClassBySpringCGLIB$$75f7873c.invoke() at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:746) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:294) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688) at com.linkyoyo.wmlink.service.impl.DataShowServiceImpl$$EnhancerBySpringCGLIB$$eaf288ce.getSpeedDateRWDByTowerId() at com.linkyoyo.wmlink.controller.DataShowControllerTest.allData(DataShowControllerTest.java:44) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:73) at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:83) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
发生了。
public MongoCursor<Document> getAllDateRWDByTowerId(Integer towerId) {
MongoCollection<Document> mongoCollection = mongoTemplate.getCollection("rwd");
FindIterable<Document> findIterable = collection.find().sort(Sorts.orderBy(Sorts.descending("date")));
return fi.iterator();
}
我尝试了一些不同的方法,总是发生同样的错误。我不知道为什么会发生以及如何解决这个问题。
最佳答案
错误是:
Sort operation used more than the maximum 33554432 bytes of RAM
蒙戈Sort Operations :
If MongoDB cannot use an index to get documents in the requested sort order, the combined size of all documents in the sort operation, plus a small overhead, must be less than 32 megabytes.
解决方案是向排序字段添加索引。请参阅here了解更多详情。
关于java - 如何使用MongoTemplate按顺序获取结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52964188/
已关闭。此问题需要 debugging details 。目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and the
我已经在 Spring Boot 中配置了 MongoDB 连接。现在我想使用 MongoTemplate find() 方法运行自定义查询。但 Spring Boot 不允许我这样做。 @Autow
从 1.9.0.RELEASE 开始,spring-data-mongodb 支持批量更新。 BulkOperations ops = template.bulkOps(BulkMode.UNORDE
我有一个名为 collection_One 的集合.我想重命名集合,但失败了。 mongotemplate给我看了: executing the 'renameCollection' command
MongoTemplate 不返回结果。 JSON: { "_id" : ObjectId("51acf6ab0d5d46077ae12b2a"), "docType" : "row",
我正在使用 MongoTemplate 来执行我的 Mongo 查询。我想知道计数是否适用于限制集? 尽管设置了限制,为什么查找查询会搜索完整集合(根据查询)?例如我写的查询可能会产生 10000 条
我正在尝试使用 MongoTemplate 和聚合框架在 Spring Boot 项目中运行聚合管道。 我的查询执行时没有任何异常。但是,当我尝试在 AggregationResults 实例上调用
我正在尝试从 mongoDb 中的嵌入字段数组中删除一个项目。数组是一种字符串类型,如下所示。 { _id: 1, fruits: [ "apples", "pears", "orange
对于 Upsert MongoTemplate 提供了一种按以下方式使用的方法。 但是,它只会设置名称。如果我想插入与新用户对象关联的所有键该怎么办?即除了姓名之外,我还想插入电子邮件和许多其他值。我
我需要在 MongoTemplate 中提取子文档,但不知道该怎么做。 我保存的文档是: { "_id" : "FooUser", "_class" : "com.domain.Use
我需要编写一个查询,它可以查找数据库中子数组大小大于某值的对象。 我的对象看起来像: { "_id" : ObjectId("sbg8732god78"), "studentIds"
我有一个端点,它接受文档 ID,以及我想要更新的嵌套数组中的 Employee 对象。这工作正常。我尝试修改端点以获取超过 1 名员工并让它一次更新所有员工,但我无法让它工作。我不确定我是否格式错误,
我想创建一个 DAO,将用户保存到我的数据库中。他们应该有唯一的登录名,这有点问题,因为 mongo db 没有事务。我有一个类,其中的用户如下所示: @Document(collection = "
我正在尝试转换以下查询: { "cd" : { "$lte" : ISODate("2013-06-30T09:12:29Z") , "$gte" : ISODate("2013-06-11T09:1
我的以下 mongodb 查询按预期工作 db.importedDataItems.aggregate({ $match: { mobile: "1234567890"
我正在根据多个参数生成一个复杂的 Mongo 查询。我想用 Criteria 辅助类制定的标准之一是: {"field1": {$exists: true, $ne: false}} 我试着用: Cr
在我们的应用程序中,我们管理许多 MongoTemplate 实例,每个实例代表一个客户端数据库。对于大多数数据库操作,我们希望使用 secondaryPreferred 读取首选项,以便利用集群的只
我在 MongoDB 中有像这样的 JSON 文档 { "os" : "Windows 10" } { "os" : "WINDOWS 8" } { "os" : "UBunTu 18.0
我正在使用 MongoTemplate 进行我的数据库操作。现在我想从所选结果中获取最大字段值。有人可以指导我如何编写查询,以便当我将查询传递给 find 方法时,它将返回我所需的最大文档字段。提前致
我有一个 Entity 类,它是一个包含基本字段的抽象类。考虑以下代码: Entity entity = new DogEntity() mongoTemplate.save(entity) 在这种情
我是一名优秀的程序员,十分优秀!