jeudi 17 octobre 2019

MongoDB random sample based on field (chance)

In the app I'm building I need to randomly get N records from a collection. But the chance of a record to appear in the sample should depend on the probability field of that record. The higher the probability field value is - the more likely that record will appear in a sample.

Is it possible to handle such functionality using MongoDB aggregation?




Aucun commentaire:

Enregistrer un commentaire