mongodb 提示 no geo indices for geoNear

{ [MongoError: exception: geoNear command failed: { ok: 0.0, errmsg: "no geo indices for geoNear" }]
  name: 'MongoError',
  message: 'exception: geoNear command failed: { ok: 0.0, errmsg: "no geo indices for geoNear" }',
  errmsg: 'exception: geoNear command failed: { ok: 0.0, errmsg: "no geo indices for geoNear" }',
  code: 16604,
  ok: 0 }

原因是你指定的 feild 的 index 不是坐标.

db.bingos.createIndex({loc: "2dsphere"})
    原文作者:kelvinlee
    原文地址: https://segmentfault.com/a/1190000005656799
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞