Add hash function (eg. md5) to aggregation pipeline
I would like to implement hash-based sharding in my own application on top of MongoDB. For that purpose, I would like to pull a stable pseudorandom subset of documents into each of my servers, and I would like to do so without enlarging the documents by adding additional fields, and without using JavaScript in the aggregation pipeline (for performance reasons).
The idea: add a hash function, such as md5, to aggregation pipelines. The function would accept an object/array containing the data to be hashed, and would return the hash, ideally as a number.
1
vote
![](https://secure.gravatar.com/avatar/448ff8d0ae7cf7011026531a2e62133c?size=40&default=https%3A%2F%2Fassets.uvcdn.com%2Fpkg%2Fadmin%2Ficons%2Fuser_70-6bcf9e08938533adb9bac95c3e487cb2a6d4a32f890ca6fdc82e3072e0ea0368.png)