我有一个geoNear命令:
{
"geoNear": "user",
"near": [
104.4859511,
10.3804459
],
"spherical": true,
"distanceMultiplier": 6371000,
"minDistance": 0.038378767752844,
"maxDistance": 0.47088369172814,
"num": 6
}
我检索mongo DB,返回一些数据:
"results": [
{
"dis": 244511.13644192,
"obj": {
"_id": ObjectId("540af074e4b06192b9481436"),
"user_id": NumberInt(219372),
"full_name": "Guest_219372",
"avatar": "",
"birthday": ISODate("2002-01-05T17:00:00.0Z"),
"sex": NumberInt(0),
"feeling": "",
"voice_intro": "",
"location": [
106.684767,
10.785003
],
"last_update": NumberInt(0),
"last_update_location": NumberInt(1410002680)
}
}
]
我想在mongo官方网站的帮助下使用“查询”仅限几个字段限制数据,但它不会返回数据。我无法在命令geoNear中检查查询的对与错。我试图聚合,发现它支持$ project,geoNear更简单。我正在使用minDistance想要你的客户端,不支持聚合minDistance,迫使我采取命令geoNear。
{
"geoNear": "user",
"near": [
104.4859511,
10.3804459
],
"spherical": true,
"distanceMultiplier": 6371000,
"minDistance": 0.038378767752844,
"maxDistance": 0.47088369172814,
"num": 6,
"query": {
"find": {
"user_id": true,
"_id": false
...
}
}
}