I have the bellow query to MongoDB:
public void query11(String product, int limit) {
printBlock = new Consumer<UserBson>() {
@Override
public void accept(final UserBson user) {
System.out.println("Hola");
if (cantResults < limit) {
System.out.println("#=[" + (cantResults + 1) + "]\t_id:" + user.getId() );
cantResults++;
}
}
};
connect.getCollection().aggregate(
Arrays.asList(
Aggregates.match(Filters.exists("scores")),
Aggregates.unwind("$scores"),
Aggregates.project(Projections.include("name", "secondName", "lastName", "secondLastName", "sales.products.name")),
Aggregates.sort(Sorts.ascending("_id"))
)
).forEach(printBlock);
totalTime = (System.currentTimeMillis() - startTimeT);
}
But Mongo is responding with:
Preformatted textException in thread āmainā com.mongodb.MongoCommandException:
Command failed with error 16819 (Location16819): āSort exceeded memory limit of 104857600 bytes, but did not opt in to external sorting. Aborting operation. Pass allowDiskUse:true to opt in.ā on server 127.0.0.1:27017. The full response is {āokā: 0.0, āerrmsgā: āSort exceeded memory limit of 104857600 bytes, but did not opt in to external sorting. Aborting operation. Pass allowDiskUse:true to opt in.ā, ācodeā: 16819, ācodeNameā: āLocation16819ā}