I am using MongoDB cursor to find documents in my spring boot application as follows:
Criteria matchCriteria = new Criteria("timestamp").lt(100);
MongoCursor<Document> cursor =
mongoTemplate
.getCollection("collectionName")
.find(new Query(matchCriteria).getQueryObject())
.sort(ascending("sortField"))
.limit(10000)
.noCursorTimeout(true)
.batchSize(10000)
.allowDiskUse(true)
.cursor();
It seems that this works fine if collectionName
is regular MongoDB collection, but if the collection is Time Series collection I am getting error:
Command failed with error 168 (InvalidPipelineOperator): 'Option noCursorTimeout not supported in aggregation.
If I remove .noCursorTimeout(true)
, this works fine. Why is it so? Any workaround so that I can include noCursorTimeout
for Time Series collection as well?