Mongo 和 find 始终限制为 100 个地理数据 [英] Mongo and find always limited to 100 with geo data

查看:20
本文介绍了Mongo 和 find 始终限制为 100 个地理数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在尝试测试 mongo 性能时,我发现我的 mongo db 出现了奇怪的行为.

While trying to experiment with mongo performance I found strange behaviour of my mongo db.

首先我用以下查询填充它:

First of all i filled it with the following query:

for (i=0; i < 10000000; i++){db.location.insert( {_id: Math.floor((Math.random()*10000000000)+1), position: [Math.round(Math.random()*10000)/10000, Math.round(Math.random()*10000)/10000]} )}

下一个:

db.location.ensureIndex( {position: "2d"} )

然后我执行查询:

db.location.find( {position: { $near: [1,1], $maxDistance: 1/111.12  } } )

无论我尝试做什么,我总是得到大小或计数结果 100.

Whatever i try to do i get always size or count result 100.

我在文档中注意到默认限制为 100.我还尝试使用大于 100 的值覆盖它.不幸的是我失败了.

I noticed in documentation that defualt limit is 100. I tried also to override it with bigger than 100 values. Unfortunately I failed.

你遇到过这样的情况吗?

Have you ever encountered such a case?

推荐答案

获取所有文档查询like

To get all document query like

cordinate = [1,1];
maxDistance = 1/111.12 ;

db.location.find({"position" : {"$within" : 
                                      {"$center" : [cordinate , maxDistance ]}
                                }
                  });

这篇关于Mongo 和 find 始终限制为 100 个地理数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆