我只是想让一个简单的near查询工作.这是我的文档样本.
{"point":
{"type": "Point",
"coordinates": [30.443902444762696, -84.27326978424058]},
"created_on": {"$date": 1398016710168},
"radius": 180,
"user": {"$oid": "53543188eebc5c0cc416b77c"},
"_id": {"$oid": "53544306eebc5c0ecac6cfba"},
"expires_on": {"$date": 1399831110168}
}
Run Code Online (Sandbox Code Playgroud)
和mongod我尝试了命令:
db.bar.find({point: {$near: [-84.26060492426588, 30.45023887165371]}});
Run Code Online (Sandbox Code Playgroud)
但我得到这个错误:
错误:{"$ err":"无法执行查询:错误处理查询:ns = foo.bar skip = 0 \nTree:GEONEAR field = point maxdist = 1.79769e + 308 isNearSphere = 0 || First:notFirst:full path :point \nSort:{} \nProj:{} \n planner返回错误:无法找到$ geoNear查询的索引","代码":17007}
也许我的谷歌今天不是那么尖锐,但我找不到任何东西.另外,我运行了ensure index命令.我的意图是这些是地图位置.
db.bar.ensureIndex({a:1});
db.bar.ensureIndex({geo:"2d"});
Run Code Online (Sandbox Code Playgroud)