[SERVER-8904] The data type of a value is causing error: { "$err" : "requested keyPattern does not match specified keys", "code" : 10365 } Created: 07/Mar/13 Updated: 19/Mar/13 Resolved: 11/Mar/13 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | 2.0.2, 2.2.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Carl Youngblood | Assignee: | Aaron Staple |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Operating System: | ALL |
| Steps To Reproduce: | Please see description |
| Participants: |
| Description |
|
> db.challenge_157_daily_scores.find().hint( ).sort( )._addSpecial('$returnKey',true).min( ).max( , , ... } Looks good! > db.challenge_157_daily_scores.find().hint( ).sort( )._addSpecial('$returnKey',true).min( ).max( , , ... } Changing d from an integer (1) to an ISODate shouldn't affect the keyPattern. |
| Comments |
| Comment by Carl Youngblood [ 11/Mar/13 ] | |||||||||||||||||||||||||||
|
Thank you! | |||||||||||||||||||||||||||
| Comment by Aaron Staple [ 11/Mar/13 ] | |||||||||||||||||||||||||||
|
Hi Carl - I'm going to close this as "works as designed" but feel free to reopen if you have further questions. | |||||||||||||||||||||||||||
| Comment by Aaron Staple [ 11/Mar/13 ] | |||||||||||||||||||||||||||
|
Hi Carl, The main thing to keep in mind here is that you cannot specify a max bound that compares less than your min bound. Here are your min and max bounds in the different examples: 1: max {g:1,d:ISODate('2013-01-01'),s:{},i:1,t:1} In this case, 'g' and 'd' are equal. The 's' field is an object in max and a number in min. Objects generally compare greater than numbers, however in this case you have specified descending comparison on the 's' field so {} will be considered less than 700 and the min / max values are not allowed. 2: max {g:1,d:ISODate('2013-01-01'),s:1,i:{},t:1} In this case, 700 > 1 so compares "less" because of the descending order on the 's' field. 3: max {g:1,d:1,s:{},i:1,t:1} Because there is an equality on 'g', ordering is based on the 'd' field. Generally a date compares greater than a number, but since you have a descending order on the 'd' field min will be less than max so your min and max are allowed. | |||||||||||||||||||||||||||
| Comment by Carl Youngblood [ 09/Mar/13 ] | |||||||||||||||||||||||||||
|
My bad! Thank you for correcting my Min/MaxKey syntax. However, it does mean that my previous use of {'$minKey':1}was just a plain object, so there still seems to be inconsistent behavior.
Thanks for all your help! | |||||||||||||||||||||||||||
| Comment by Aaron Staple [ 08/Mar/13 ] | |||||||||||||||||||||||||||
|
Hi Carl - I don't think { $minElement:1 }and { $maxElement:1 }can be sent to the server in this form. From the shell I think you can do:
| |||||||||||||||||||||||||||
| Comment by Carl Youngblood [ 08/Mar/13 ] | |||||||||||||||||||||||||||
|
Here is a less messy copy and paste. Please note the only difference between query 1 and 2 is the change to the value of the d key in the max parameter. // Query 1 ).min( {g:1,d:ISODate('2013-01-01'),s:700,i:0,t:0}).max({g:1,d:ISODate('2013-01-01'),s: {'$minElement':1},i: {'$maxElement':1},t:{'$maxElement':1}}) // Query 2 ).min( {g:1,d:ISODate('2013-01-01'),s:700,i:0,t:0}).max({g:1,d:1,s: {'$minElement':1},i: {'$maxElement':1},t:{'$maxElement':1}}) { "_id" : ObjectId("5139406d0518ed58a08d64c0"), "g" : [ 1 ], "d" : ISODate("2013-01-01T00:00:00Z"), "s" : 700, "i" : 0, "t" : 0 } { "_id" : ObjectId("513940700518ed58a08d64c1"), "g" : [ 1 ], "d" : ISODate("2013-01-01T00:00:00Z"), "s" : 600, "i" : 0, "t" : 0 } { "_id" : ObjectId("513940740518ed58a08d64c2"), "g" : [ 1 ], "d" : ISODate("2013-01-01T00:00:00Z"), "s" : 500, "i" : 0, "t" : 0 } { "_id" : ObjectId("513941f60518ed58a08d64c9"), "g" : [ 1, 2 ], "d" : ISODate("2013-01-01T00:00:00Z"), "s" : 350, "i" : 0, "t" : 0 } | |||||||||||||||||||||||||||
| Comment by Carl Youngblood [ 07/Mar/13 ] | |||||||||||||||||||||||||||
|
The ellipses everywhere are just from copy pasting from my shell, if it really bugs you I can edit them out. |