Description
mongodb version 3.6.23
jdk 11
system: MacOS 12.4
Criteria criteria = Criteria.where("token").is("true");
Query query = new Query(criteria).maxTimeMsec(1000);;
long count = mongoTemplate.count(query, DBObject.class, "public_leads");
The desired effect is that after 1 second of execution, if it doesn't compute, then immediately break it. But this will not happen, and count() will complete the entire evaluation without being interrupted by a query timeout
db.collection.count({query}, {maxTimeMS: 1000})
Native mongodb js queries work, but not in the framework, I tried the two versions respectively, spring-data-mongodb version: 3.4.11 , 4.0.5 will be repeated
Criteria criteria = Criteria.where("token").is("true");
Query query = new Query(criteria).maxTimeMsec(1000);
List list = mongoTemplate.find(query, DBObject.class, "public_leads");
There's no problem with using it that way