Mongodb 如何在命令geoNear中通过查询自定义字段?

Mongodb 如何在命令geoNear中通过查询自定义字段?,mongodb,geolocation,nosql,Mongodb,Geolocation,Nosql,我有一个geoNear命令: { "geoNear": "user", "near": [ 104.4859511, 10.3804459 ], "spherical": true, "distanceMultiplier": 6371000, "minDistance": 0.038378767752844, "maxDistance": 0.47088369172814, "num": 6 } 我检索mongo DB,返回一些数据: "results": [ {

我有一个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,使事情更简单。我正在使用MindEstance想要你的客户,不支持聚合MindEstance,强迫我接受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
            ...
        }
    }
} 

MindInstance由聚合$geoNear支持,只是没有文档记录。你自己试试。谢谢尼尔·伦!我将尝试使用聚合。但是有没有办法处理查询命令geoNear not?我很清楚您期望的最终结果是什么,主要是因为您似乎没有这么说。MongoDB 2.6有$near和$nearSphere,它们集成到标准查询引擎中。聚合$geoNear允许投影距离字段。我需要两个位置的距离(使用2dsphere类型)。如果我通过查询得到结果,mongo将帮助我计算距离,我不相信第三方的算法。。。