Zoned and hashed sharding of existing, non-empty collection I am trying to shard a existing collection. Collection is pretty big (about 100gb). Sharding should be done by 2 fields. First one is zone ['Europe', 'America'] and second one is _id.
So my sharding index looks like this {&quot;zone&quot;: 1, &quot;_id&quot;: &quot;hashed&quot;}.
I have followed these steps https://docs.mongodb.com/manual/reference/method/sh.updateZoneKeyRange/#compound-hashed-shard-key-with-non-prefix-hashed-field. This works only on empty or non existing collection. My question is is this type of sharding possible on collection that is not empty.
I am using mongo version 4.4
For me it is working. You only need to create the index { &quot;region&quot;: 1, &quot;_id&quot;: &quot;hashed&quot; } manually.
use data
db.collection.insertMany([{ region: 'EU' }, { region: 'US' }])

sh.addShardToZone(&quot;shard_01&quot;, &quot;Europe&quot;)
sh.addShardToZone(&quot;shard_02&quot;, &quot;America&quot;)

sh.updateZoneKeyRange(
   &quot;data.collection&quot;,
   { &quot;region&quot;: &quot;EU&quot;, &quot;_id&quot;: MinKey },
   { &quot;region&quot;: &quot;EU&quot;, &quot;_id&quot;: MaxKey },
   &quot;Europe&quot;
)

sh.updateZoneKeyRange(
   &quot;data.collection&quot;,
   { &quot;region&quot;: &quot;US&quot;, &quot;_id&quot;: MinKey },
   { &quot;region&quot;: &quot;US&quot;, &quot;_id&quot;: MaxKey },
   &quot;America&quot;
)

db.collection.createIndex({ &quot;region&quot;: 1, &quot;_id&quot;: &quot;hashed&quot; })
sh.shardCollection(
   &quot;data.collection&quot;,
   { &quot;region&quot;: 1, &quot;_id&quot;: &quot;hashed&quot; }
)

Extract from sh.status():
data.collection
  shard key: { &quot;region&quot; : 1, &quot;_id&quot; : &quot;hashed&quot; }
  unique: false
  balancing: true
  chunks:
          shard_01  2
          shard_02  1
          shard_03  1
          shard_04  1
  { &quot;region&quot; : { &quot;$minKey&quot; : 1 }, &quot;_id&quot; : { &quot;$minKey&quot; : 1 } } --&gt;&gt; { &quot;region&quot; : &quot;EU&quot;, &quot;_id&quot; : { &quot;$minKey&quot; : 1 } } on : shard_04 Timestamp(3, 0) 
  { &quot;region&quot; : &quot;EU&quot;, &quot;_id&quot; : { &quot;$minKey&quot; : 1 } } --&gt;&gt; { &quot;region&quot; : &quot;EU&quot;, &quot;_id&quot; : { &quot;$maxKey&quot; : 1 } } on : shard_01 Timestamp(4, 1) 
  { &quot;region&quot; : &quot;EU&quot;, &quot;_id&quot; : { &quot;$maxKey&quot; : 1 } } --&gt;&gt; { &quot;region&quot; : &quot;US&quot;, &quot;_id&quot; : { &quot;$minKey&quot; : 1 } } on : shard_03 Timestamp(4, 0) 
  { &quot;region&quot; : &quot;US&quot;, &quot;_id&quot; : { &quot;$minKey&quot; : 1 } } --&gt;&gt; { &quot;region&quot; : &quot;US&quot;, &quot;_id&quot; : { &quot;$maxKey&quot; : 1 } } on : shard_02 Timestamp(2, 0) 
  { &quot;region&quot; : &quot;US&quot;, &quot;_id&quot; : { &quot;$maxKey&quot; : 1 } } --&gt;&gt; { &quot;region&quot; : { &quot;$maxKey&quot; : 1 }, &quot;_id&quot; : { &quot;$maxKey&quot; : 1 } } on : shard_01 Timestamp(1, 5) 
   tag: Europe  { &quot;region&quot; : &quot;EU&quot;, &quot;_id&quot; : { &quot;$minKey&quot; : 1 } } --&gt;&gt; { &quot;region&quot; : &quot;EU&quot;, &quot;_id&quot; : { &quot;$maxKey&quot; : 1 } }
   tag: America  { &quot;region&quot; : &quot;US&quot;, &quot;_id&quot; : { &quot;$minKey&quot; : 1 } } --&gt;&gt; { &quot;region&quot; : &quot;US&quot;, &quot;_id&quot; : { &quot;$maxKey&quot; : 1 } }

Please be aware of Balancing failed when moving big collection, my collection is also around 100GB, so you may face the same issue.