bill_cosby
bill_cosby

Reputation: 145

MongoDB returns wrong results for count query

> filters = {search_created_at: {$lte: ISODate("2016-04-28T23:25:31.818Z")}}
{ "search_created_at" : { "$lte" : ISODate("2016-04-28T23:25:31.818Z") } }
> db.collection_name.find(filters).count()
18371526
> 
> db.collection_name.find().count()
18371316
> 

Total count for a collection comes out to be less than filtered count. Weird. If anyone could help??? TIA

Upvotes: 0

Views: 397

Answers (1)

profesor79
profesor79

Reputation: 9473

this could be corrupted index issue, try rebuild indexes and run your query again

db.collection.reIndex()

more here

Upvotes: 1

Related Questions