"Please create an index that starts with the proposed shard key before sharding the collection" - SOLVED

Maybe this is the same problem - but I’ve been dealing with it for more than 10 minutes - so I’m not sure.

I’m getting the same message. Running db.m103.products.getIndexes(), my added index has “ns” field value of “test.products”, which seems a little worrisome. It seems like it should be “m103.products”.

I did successfully shard “test.products” with the key I created. Of course when I ran the validation script it failed because it’s looking for “m103.products”.

I have a feeling this has something to do with file structure/pathing in Unix - which I’m not very familiar with. So I’m not sure what I’m supposed to do to fix this seeming namespace problem.

Wow. Somehow I missed the fact that you’ve got to “use products” before you can createIndex.

2 Likes