The arguments to `$min` and `$max` are order-dependent. If you have an index on a, b and query for `$max: {b: 1, a: 1}` the server throws "no index found for specified keyPattern". So `spec` should be a `bson.son.SON`, not a `dict`. I suggest adding a function to common.py called `validate_index_key` that raises `TypeError` unless `spec` is a `SON` whose keys are all `basestring`. Call that function here and in `min()`.