MongoDB 在地理空间查询上计数不准确
我正在查询靠近某个位置($near
和 $maxDistance
)且在某个日期范围内($or
)的文档包含 3 组与日期/日程相关的 $gt
/$lt
条件)。
我发现,无论 limit()
如何,即使有 100 个或更多结果,$cursor->count()
也总是返回 100。
看起来 $cursor->skip()->limit()
工作正常,允许我跳过 100 多个结果(当超过 100 个时),但令我困扰的是 < code>count() 总是返回 100,并且似乎没有办法确定完整计数(除了分页直到没有更多结果)。
我找到了对 地图缩减无法与地理空间正常工作的引用,并且 mongodb 文档引用了默认 limit()
为 100。
上面的查询找到最接近 (50,50) 的点,并返回按距离排序的点(不需要额外的排序参数)。使用 limit() 指定要返回的最大点数(如果未指定,则应用默认限制 100):
这是一个已知问题吗?我正在使用 PHP 驱动程序。
I'm querying for documents that are close to a location ($near
and $maxDistance
) and fall within a date range (an $or
with a 3 sets of $gt
/$lt
conditions relating to dates/schedules).
I find that $cursor->count()
always returns 100 even if there are 100 or more results regardless of limit()
.
It seems like $cursor->skip()->limit()
work fine, allowing me to skip more than 100 results (when there are more than 100), but it bothers me that count()
always returns 100 and there seems to be no way to determine the full count (other than paging until there are no more results).
I find references to map reduce not working correctly with geospatial, and the mongodb docs reference a default limit()
of 100.
The above query finds the closest points to (50,50) and returns them sorted by distance (there is no need for an additional sort parameter). Use limit() to specify a maximum number of points to return (a default limit of 100 applies if unspecified):
Is this a known issue? I'm using the PHP driver.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
等待向 geo-spital 添加 $ 或 $ 和支持一年:
https://jira.mongodb .org/browse/SERVER-3984
__
也许他们会在 2014 年支持这个;)
__
http://pastebin.com/raw.php?i=FD3xe6Jt
http://www.zopyx.de/blog/goodbye-mongodb
http://blog.engineering.kiip.me/post/20988881092/a -year-with-mongodb
http://blog.schmichael.com/2011/11/05/failing-与-mongodb/
Waiting for add $or $and support to geo-spital for a year:
https://jira.mongodb.org/browse/SERVER-3984
__
maybe they support this due 2014 ;)
__
http://pastebin.com/raw.php?i=FD3xe6Jt
http://www.zopyx.de/blog/goodbye-mongodb
http://blog.engineering.kiip.me/post/20988881092/a-year-with-mongodb
http://blog.schmichael.com/2011/11/05/failing-with-mongodb/