Issue
As the title indicates, I am getting the error that I should use the cursor option with the following code:
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();
}
We recently upgraded from mongo version 3.5.5 to 4.4.0 in order to support the merge operation (supp since 4.2.0) and now we receive this error. Keep in mind that this is the reactive mongo template, coming from org.springframework.data.mongodb.core
(currently at version 3.2.2).
I did try to add cursorBatchSize
and cursor
in the aggregation options without any result, or I'm doing something wrong there? I'm just wondering if its already available for the reactive mongo template at all. This is also an embedded mongo instance from the flapdoodle library.
Full error: InvalidDataAccessApiUsageException "The 'cursor' option is required, except for aggregation explain", "code": 9, "codeName": "FailedToParse"
Solution
So we just went from an embedded to a dockerized mongo instance, this resolved a lot of issues e.g. machine os
Answered By - BrianM