In my mongodb setup I have a compound shard key {"region" : 1, "foo" : 1, "bar" : 1}
and I know the values region can be and that each region should be on one chunk.
Therefore I'd like to pre-split based on the region key only. The sharding status should look like that afterwards:
{ "region": { "$minKey" : 1 }, "foo": { "$minKey" : 1 }, "bar": { "$minKey" : 1 } } -> { "region": region1, "foo": { "$minKey" : 1 }, "bar": { "$minKey" : 1 } } on: shard1
{ "region": region1, "foo": { "$minKey" : 1 }, "bar": { "$minKey" : 1 } } -> { "region": region2, "foo": { "$minKey" : 1 }, "bar": { "$minKey" : 1 } } on: shard2
{ "region": region2, "foo": { "$minKey" : 1 }, "bar": { "$minKey" : 1 } } -> { "region": { "$maxKey" : 1 }, "foo": { "$minKey" : 1 }, "bar": { "$minKey" : 1 } } on: shard3
I've tried some ways to achieve that, but nothing worked:
db.runCommand( { split : "mydb.mycollection" , middle : { "region" : "region1" } } );
will return an error, because the complete shard key have to be part of the split.db.runCommand( { split : "mydb.mycollection" , middle : { "region" : "region1", "foo" : { "$minKey" : 1 }, "bar" : { "$minKey" : 1 } } } );
anddb.runCommand( { split : "mydb.mycollection" , middle : { "region" : "region1", "foo" : "$minKey" , "bar" : "$minKey" } } );
will interpret the minKey as String and split on that base which is wrong.
How can I finally split chunks with a compound shard key on a single field base?!
Cheers.