【发布时间】:2018-05-05 06:37:21
【问题描述】:
我found, that to select random document,我需要使用$sample命令:
// Get one random document from the mycoll collection.
db.mycoll.aggregate(
{ $sample: { size: 1 } }
)
但是如果我需要过滤文档然后随机抽取一个呢?
我正在处理尚未处理的文档
query = {'start_time': {'$exists': False}}
hp_entries = mongo.hyperparameters_collection.find(query)
我将如何处理随机数?
【问题讨论】:
标签: mongodb python-3.x pymongo