Error MongoDB - geoNear "no geo indices"

0

To get a MongoDB database I use the following code:

    router.get('/multibancos', function(req, res, next){
    MB.aggregate().near({
      near: { type: "Point", coordinates: [parseFloat(req.query.lng) , parseFloat(req.query.lat)] },
                  distanceField: "dist.calculated",
                  maxDistance: 100000,
                  spherical: true
      }).then(function(mb){
          res.send(mb);
      }).catch(next);
  });

and call with the following link:

localhost:4000/api/multibancos/?lng=80&lat=-20

It turns out that it gives me the error:

    {
    "error": "geoNear command failed: { ok: 0.0, errmsg: \"no geo indices for geoNear\" }"
}
    
asked by anonymous 08.02.2018 / 23:19

0 answers