【发布时间】:2022-01-09 22:53:58
【问题描述】:
正如标题所示,我收到错误消息,我应该使用以下代码使用光标选项:
public Mono<Test> someMethod(String param) {
return reactiveMongoTemplate.aggregate(Aggregation.newAggregation(X.class,
Aggregation.match(Criteria.where("test").is(param)),
Aggregation.group("field")
.first("value").as("value")
.first("test").as("test"),
Aggregation.group()
.first("test").as("test")
.push(new BasicDBObject()
.append("k", "$_id")
.append("v", "$value")
)
.as("array"),
Aggregation.replaceRoot(
MergeObjects.merge(
new BasicDBObject().append("_id", "$test"),
ArrayToObject.arrayValueOfToObject("array")
)
),
Aggregation.project(getFields()),
Aggregation.merge()
.into(MergeOperationTarget.collection("test"))
.on("id")
.build()
).withOptions(AggregationOptions.builder().allowDiskUse(true).build()), Test.class)
.single();
}
我们最近从 mongo 版本 3.5.5 升级到 4.4.0 以支持合并操作(自 4.2.0 起支持),现在我们收到此错误。请记住,这是响应式 mongo 模板,来自 org.springframework.data.mongodb.core(当前版本为 3.2.2)。
我确实尝试在聚合选项中添加 cursorBatchSize 和 cursor 没有任何结果,或者我在那里做错了什么?我只是想知道它是否已经可用于响应式 mongo 模板。这也是来自 fladdoodle 库的嵌入式 mongo 实例。
完全错误:InvalidDataAccessApiUsageException "The 'cursor' option is required, except for aggregation explain", "code": 9, "codeName": "FailedToParse"
【问题讨论】:
标签: java spring mongodb aggregate spring-webflux