Currently, 2dsphere index is based on human readable string, because the order of string satisfies the requirement of index. However, its size can be about 4 times larger than using an unsigned 64-bit integer, at the finest level. With index versioning, we could implement a compact version of 2dsphere index.
Since BSON doesn't support unsigned 64-bit integer, we have to work around this constraint. There are several possible solutions.
1. Add / subtract a bias between signed and unsigned 64-bit integer, then use BSON signed 64-bit integer for indexing.
2. The first 3 bits of S2CellId is for face. If we can guarantee the range search of index scan never crosses the boundary of faces, the range search will never cross 0, then two's complement representation guarantees the relative order in each face. static_cast<uint64_t> would be an option in this case.
3. Use BSON binary type to encode S2CellId, like 2d index.
4. Increase the finest level by one and shift S2CellId by two bits to make it fit in signed integer.