【发布时间】:2018-04-19 15:17:36
【问题描述】:
我正在尝试迭代 CosmosDB 的 MongoDB API 返回的结果集。我正在使用 pymongo 连接到数据库。
查询看起来像:
items = item_collection.find(filter={'store_id': 151, 'dept_id': {'$in': [17, 19]}})
但是,我只能在光标为空之前遍历 101 项目。调用items.count() 表明结果集中肯定有更多结果:
tally = 0
for item in items:
tally += 1
print('Cursor total: %s --- Tally: %s' % (items.count(), tally))
# prints 'Cursor total: 627 --- Tally: 101'
也许不是巧合,101 是 Mongo 查询返回的第一批的默认大小。
现在,如果我删除查询的 $in 部分,并发出类似以下内容:
item_collection.find(filter={'store_id': 151, 'dept_id': 17})
然后tally 和items.count() 产生相同的数字。
欢迎任何关于为什么会发生这种情况的见解!
【问题讨论】:
-
嗨,有什么更新吗?
-
@JayGong 还没有。当我听到什么时,我会在这里发布。
标签: mongodb azure pymongo azure-cosmosdb