How to group the generatd _id

Hi, I have millions of records or URL, recoeds is marely _id, Now based on _id I have to create sitemap. each sitemap can have lets say maximum of 15K records. So is there any way we can write a mapping function which will uniquely calculate the group in which this id belongs to so that groupd number can be mapped to sitemap name. You might ask why because If I have to insert a new url i should know in which sitemap I have to insert, and if I have to update or delete a url I should know which sitemap I should look at. One might argue why not also keep that sitemap name in database along with id, my answer is in that case we have to query the database to get the sitemap name, where as I want to design something staeteless method.

So I came up something in my mind if we can have some mapping function which can guarantee grouping in which no prior information is needed and also group can have a maxmimum number of elements that belongs to it. Thanks