Reputation: 689
Why a $nearsphere query always returns 100 results?
db.mytable.find({"geo":{"$nearSphere":[41.393552,2.171344999999974],"$maxDistance":0.007}}).limit(500).count() -->>> 100 results
No matter about the value of $maxdistance, my table has more than 30.000 records.
Upvotes: 2
Views: 1112
Reputation: 1
I think the asynchronous code is hitting the db.close(); before the .each loop finished, for some reason everyone is getting only 100 results, so here is a workaround.
var url = 'mongodb://localhost:27017/mydb';
MongoClient.connect(url, function(err, db) {
var i=0;
var collection = db.collection('documents');
collection.find().each(function(err, docs) {
if (docs != null){
console.log(docs);
console.log(i);
i++;
if( i >= docs.length ){
db.close();
}
}
});
});
Upvotes: 0
Reputation: 10346
Check this: https://jira.mongodb.org/browse/SERVER-739
Upvotes: 2