[SERVER-2470] sort (using an index + $exists) incorrectly excluding results Created: 02/Feb/11 Updated: 17/Mar/11 Resolved: 02/Feb/11 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Index Maintenance |
| Affects Version/s: | 1.6.5 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Visnu Pitiyanuvath | Assignee: | Unassigned |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
osx 10.6.6 |
||
| Operating System: | OS X |
| Participants: |
| Description |
|
our queries with sorts aren't returning results that really should be returned. I believe this happens when the index used by the sort doesn't include the record(s) that should be returned. here's a simple way to reproduce the problem: > db.version() ) > db.foo.find({}).sort( {c: -1}) { "_id" : ObjectId("4d49a87bff97b37303687cfa"), "a" : 1, "b" : 2 }// all ok so far > db.foo.find({c: {$exists: false}}).sort( {c: -1}) { "_id" : ObjectId("4d49a87bff97b37303687cfa"), "a" : 1, "b" : 2 }// still ok > db.foo.ensureIndex( {c: -1}) // now we have an index on the sort key > db.foo.find({c: {$exists: false}}).sort( {c: -1}) // which makes my result disappear > db.foo.find({}).sort( {c: -1}) // still ok without the $exists { "_id" : ObjectId("4d49a87bff97b37303687cfa"), "a" : 1, "b" : 2 }> db.foo.find({c: {$not: {$exists: true}}}).sort( {c: -1}) // and ok with a convoluted $not $exists { "_id" : ObjectId("4d49a87bff97b37303687cfa"), "a" : 1, "b" : 2 }this didn't happen in 10.6.3 (not sure in 10.6.4). |
| Comments |
| Comment by Visnu Pitiyanuvath [ 02/Feb/11 ] |
|
leaving closed and left a comment on |
| Comment by Aaron Staple [ 02/Feb/11 ] |
|
Probably the same as |
| Comment by Visnu Pitiyanuvath [ 02/Feb/11 ] |
|
sorry, that should read "this didn't happen in 1.6.3 (not sure in 1.6.4)." I was clarifying mongodb versions, not osx versions. |