I am probably missing something, but I just cannot understand how MongoDB defines the key ranges, in terms of type.
Say I have a collection for user profiles that look like this:
{userId : "123", profiles: [p1, p2], location: "loc"}
Then if I declare the shard key like this:
{ shardcollection : "test.user_profile", key : {"userId":1} }
How will the ranges work:
- If userId in {1 … 100000}?
- If userId is some string, like a generated UUID?
How can I define a shard key that would be treated as string, time md5 or something else?
The comparison on fields in mongo is done according the the BSON comparison order.
See here for more details.
http://www.mongodb.org/display/DOCS/What+is+the+Compare+Order+for+BSON+Types
and here for information on creating specific types
http://www.mongodb.org/display/DOCS/Data+Types+and+Conventions