[英]MongoDB (PyMongo) Pagination with distinct not giving consistent result
I am trying to achieve pagination with distinct using pymongo.我正在尝试使用 pymongo 实现不同的分页。
I have records我有记录
{
name: string,
roll: integer,
address: string,
.
.
}
I only want name for each record, where name can be duplicate, so i want distinct name with pagination.我只想要每条记录的名称,其中名称可以重复,所以我想要带有分页的不同名称。
result = collection.aggregate([
{'$sort':{"name":1}},
{'$group':{"_id":"$name"}},
{'$skip':skip},
{'$limit':limit}
])
Problem is, with this query, each time I query I get different result for same page number问题是,对于这个查询,每次我查询时,我都会得到相同页码的不同结果
Looked into this answer看了这个答案
Distinct() command used with skip() and limit() Distinct() 命令与 skip() 和 limit() 一起使用
but didn't help in my case.但在我的情况下没有帮助。
How do I resolve this.我该如何解决这个问题。
Thanks in advance!提前致谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.