Details
-
Bug
-
Resolution: Duplicate
-
Major - P3
-
None
-
None
-
None
-
ALL
Description
Using sort() on a $regex query seems to inconsistently break the $regex query:
Without sort:
> db.goog0005_Australia_may.interviews.find({'ident': {$regex: /^11952449|.*/}})
With sort:
> db.goog0005_Australia_may.interviews.find({'ident': {$regex: /^11952449|.*/}}).sort(
)
{ "_id" : ObjectId("4df92666fba522403200000a"), "ident" : "11948252|34050" } { "_id" : ObjectId("4df92666fba5224032000009"), "ident" : "11948208|34050" } { "_id" : ObjectId("4df92666fba5224032000008"), "ident" : "11947965|34050" } { "_id" : ObjectId("4df92666fba5224032000007"), "ident" : "11947861|34050" } { "_id" : ObjectId("4df92666fba5224032000006"), "ident" : "11947846|34050" } { "_id" : ObjectId("4df92666fba5224032000005"), "ident" : "11947723|34050" } { "_id" : ObjectId("4df92666fba5224032000004"), "ident" : "11944922|34050" } { "_id" : ObjectId("4df92666fba5224032000003"), "ident" : "11944870|34050" } { "_id" : ObjectId("4df92666fba5224032000002"), "ident" : "11943967|34050" } { "_id" : ObjectId("4df92666fba5224032000001"), "ident" : "11952449|34050" } { "_id" : ObjectId("4df92666fba5224032000000"), "ident" : "11952449|34050" }It gets weirder. Trying the same query a few seconds later (with sort()) returns the result set that was previously returned without sort():
> db.goog0005_Australia_may.interviews.find({'ident': {$regex: /^11952449|.*/}}).sort(
)
{ "_id" : ObjectId("4df92666fba5224032000001"), "ident" : "11952449|34050" } { "_id" : ObjectId("4df92666fba5224032000000"), "ident" : "11952449|34050" }Note: These examples are all from the mongo shell. The original report of this problem used pymongo examples to reproduce so it doesn't seem to be a shell problem.