问题是我在mongo中有这种数据:
{"_id" : ObjectId("5b3cf4731d41c809f9d7e8a8"),
"envio" : "Normal",
"tipo" : "Gaseoso",
"fecha" : ISODate("2003-12-24T00:00:00Z"),
"peso" : 21,
"volumen" : 43,
"origen" : "Cadiz",
"destino" : "Castellon",
"coordenadas_origen" : {
"type" : "Point",
"coordinates" : [
-87.835295,
36.8650496
]
},
"coordenadas_destino" : {
"type" : "Point",
"coordinates" : [
-0.0615051101057482,
40.25185675
]
},
"nombre" : "Cafes el amanencer",
"id_vagon" : 1330}
现在,我要访问的是距“ coordenadas_destino” 最近的文档,但是我从查询中得到的是距第一个坐标最近的文档,而不是第二个坐标。我的查询是这个:
db.mercancias.aggregate([{$geoNear: {near: { type: "Point", coordinates: [ -87.835295 , 36.8650496] },distanceField: "dist.calculated", maxDistance: 0.00005,spherical: true}}])
是否可以选择指示mongo必须检查的字段?
感谢您的时间。