Error that happens sometimes: no such cmd: spherical in run cmd

17 views
Skip to first unread message

Pontus Lundin

unread,
May 17, 2016, 4:45:50 AM5/17/16
to mgo-users
Hi!

For some reason i get this error sometimes  (or no such cmd:MaxDistance). Here is my code. It works mostly but then suddenly i get this error. Not sure if this is this is problem with mongodb itself or mgo.

Any ideas ?

Thanks!


query:=bson.M{

"geoNear":"oriodealers",
"near": bson.M{
"type":        "Point",
"coordinates": []float64{long, lat},
},
"maxDistance": scope,
"spherical": true,

}
err=session.DB("test").Run(query, &results)
if err != nil {
log.Fatal("err:", err)
}

 

Pontus Lundin

unread,
May 17, 2016, 4:01:58 PM5/17/16
to mgo-users
Should had read the API docs about preserving the document order in the Run commands! Added a Bson.D key value pair instead and then mongodb pick up maxDistance and spherical correctly and not trying to add that to the near command.

Thanks!
Reply all
Reply to author
Forward
0 new messages